Hello,
I'm pretty new to the macro world, but I was trying to make a macro to create a circular profile sweep with a 0.25"OD from a newly inserted (or currently selected) 3D sketch.
I do this very often so saving the few clicks and key strokes it takes would be amazing. I recorded the steps I take with the macro recorder. The problem I run into is that it only works with the first inserted sketch. Below is my code. I'm pretty sure why it's doing it. But I don't know how to change it to accept any 3d sketch. Any help is appreciated. Thank you.
' ******************************************************************************
' C:\Users\xxxxxxx\AppData\Local\Temp\swx9300\Macro1.swb - macro recorded on 08/21/17 by xxxxxxxxxx
' ******************************************************************************
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
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("3DSketch1", "SKETCH", 0, 0, 0, False, 4, Nothing, 0)
Dim myFeature As Feature
Set myFeature = Part.FeatureManager.InsertProtrusionSwept4(False, False, 0, False, False, 0, 0, False, 0, 0, 0, 0, True, True, True, 0, True, True, 0.00635, False)
End Sub
SolidworksApi macros