5 Replies Latest reply on Jan 4, 2017 9:50 AM by Kishore K.

    sweep command api example

    Vishaldeep Singh

      some example of sweep command with api code

        • Re: sweep command api example
          Deepak Gupta

          Check the example "Insert Sweep Cut Feature Example (VBA)" in SW API help files. You can use the same for InsertProtrusionSwept3

          • Re: sweep command api example
            Manikandan Babu

            Dear Vishal,

             

                                 Macro for sweep command

             

            Option Explicit

            Dim swApp As SldWorks.SldWorks

            Dim swmodel As SldWorks.ModelDoc2

            Dim swpart As SldWorks.PartDoc

            Dim tempdir As String

             

            Sub main()

            Set swApp = Application.SldWorks

            swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False

            tempdir = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplatePart)

            Set swmodel = swApp.NewDocument(tempdir, 0, 0, 0)

            swmodel.Extension.SelectByID2 "Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0

            swmodel.SketchManager.InsertSketch True

            swmodel.ShowNamedView ("*Normal To")

            'Path

            swmodel.SketchManager.CreateLine 0, 0, 0, 0, 100 / 1000, 0

            swmodel.AddDimension 15 / 1000, 15 / 1000, 0

            swmodel.SketchManager.CreateLine 0, 100 / 1000, 0, 100 / 1000, 100 / 1000, 0

            swmodel.AddDimension 15 / 1000, 15 / 1000, 0

            swmodel.SketchManager.InsertSketch True

            'Profile

            swmodel.Extension.SelectByID2 "Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0

            swmodel.SketchManager.InsertSketch True

            swmodel.SketchManager.CreateCircleByRadius 0, 0, 0, 25 / 1000

            swmodel.AddDiameterDimension2 0, 10 / 1000, 0

            swmodel.SketchManager.InsertSketch True

            'Sweep

            swmodel.Extension.SelectByID2 "Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0

            swmodel.Extension.SelectByID2 "Sketch2", "SKETCH", 0, 0, 0, True, 0, Nothing, 0

            swmodel.FeatureManager.InsertProtrusionSwept3 True, True, 0, False, False, 0, 0, True, 2 / 1000, 0, 1, 0, True, True, True, 0, False

            End Sub

             

             

            Manikandan B

            EGS Computers India Pvt Ltd

            http://www.egsindia.com

            http://www.egs.co.in