I am trying to write a simple macro that will insert a predefined block then explode it. Here is the code that SW generates when recording the macro:
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("Sheet1", "SHEET", 0.4346699697885, 0.3967817643505, 0, False, 0, Nothing, 0)
Part.EditTemplate
Part.EditSketch
Part.ClearSelection2 True
Dim myBlockInstance As Object
Set myBlockInstance = Part.SketchManager.InsertSketchBlockInstance(Nothing, Nothing, 1, 0)
boolstatus = Part.Extension.SelectByID2("RevBlock1-5", "SUBSKETCHINST", 0.5511907432024, 0.02999962537764, 0, False, 0, Nothing, 0)
Part.SketchManager.ExplodeSketchBlockInstance Nothing
boolstatus = Part.Extension.SelectByID2("Sheet Format1", "SHEET", 0.3881764592145, 0.3233105377644, 0, False, 0, Nothing, 0)
Part.EditSheet
Part.EditSketch
Part.ClearSelection2 True
End Sub
When I try to run the macro is get the following message: "Internal Application Error" and it highlights the red line above in the debugger.
Thanks for your help!
(Macro file is attached)
SolidworksApi macros