hi all.
im beginner in macros, i was record a macro and after run, solidworks put the sketches in other planes that a set and not finish the operations, this operations are standar operation (extrude and cut extrude).
can you help me?
this is the code
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.ClearSelection2 True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.064427, 0.019697, 0#)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.ShowNamedView2 "*Trimetric", 8
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.4, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True, True, True, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False
Part.ViewZoomtofit2
boolstatus = Part.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ShowNamedView2 "*Top", 5
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.CreateCircle(0#, -0.220209, 0#, 0.039164, -0.208236, 0#)
Dim myModelView As Object
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.FeatureCut3(True, False, False, 6, 0, 0.4, 0.4, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, False, True, True, True, True, False, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False
End Sub
SolidworksApi macros