1 Reply Latest reply on Feb 13, 2014 9:45 PM by Gustavo Oliveira

    What is the best way to insert a sketch

    Jamie Lill

      I have created a cylinder with APi. I want to insert a sketch on the end of the cylinder and cut extrude thru the hole body..

      There are two parts to this question

       

       

      (1) What is the best way to identify the face It was created at 0,0,0.

       

      (2) I have 50 standard but dissimilar shapes that I want to create.

       

           I could create a form with a button or listbox to draw each shape

           or should I put these shapes into some sort of data table.

       

      The shapes might have 20 lines for the most common to 1 circle to he simplest

       

      If you have any examples that would be great

       

      Thanks

        • Re: What is the best way to insert a sketch
          Gustavo Oliveira

          Try this macro: This macro will create a body and a hole using the same plane.

           

          Dim swApp As Object

          Dim Part As Object

           

          Sub main()

           

          Set swApp = Application.SldWorks

          Set Part = swApp.ActiveDoc

           

          ' ******************

          ' Create Body Circle

          ' ******************

           

          Part.ClearSelection2 True

           

          Part.Extension.SelectByID2 "Front", "PLANE", 0, 0, 0, False, 0, Nothing, 0

           

          Part.SketchManager.CreateCircle 0#, 0#, 0#, 0.016, 0#, 0#

           

          ' *********************

          ' Create Body Extrusion

          ' *********************

           

          Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.01, 0.01, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False

          Part.SelectionManager.EnableContourSelection = False

           

          ' ******************

          ' Create Hole Circle

          ' ******************

           

          Part.ClearSelection2 True

           

          Part.Extension.SelectByID2 "Front", "PLANE", 0, 0, 0, False, 0, Nothing, 0

           

          Part.SketchManager.CreateCircle 0#, 0#, 0#, 0.008, 0#, 0#

           

          ' *********************

          ' Create Hole Extrusion

          ' *********************

           

          Part.FeatureManager.FeatureCut3 True, False, True, 1, 0, 0, 0, False, False, False, False, 0, 0, False, False, False, False, False, True, True, True, True, False, 0, 0, False

          Part.SelectionManager.EnableContourSelection = False

           

          Part.ClearSelection2 True

           

          End Sub