Hello
I want to make a macro (SW2019) in order to automatically create blocks from the 2D sketches.
Sketches are a single layer in a dxf file.
So I open up the dxf and I end up with different 2D sketches.
Here is the code of the macro generated by recording with comments...:
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
'Selection of the "top support" sketch
boolstatus = Part.Extension.SelectByID2("top press", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Dim myBlockDefinition As Object
Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromSelected(Nothing) ' Creating the block
'Selection of the "bottom points" sketch
boolstatus = Part.Extension.SelectByID2("bottom tips", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromSelected(Nothing) ' Creating the block
'Selection of the sketch "wedges pm"
boolstatus = Part.Extension.SelectByID2("cales pm", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromSelected(Nothing) ' Creating the block
End Sub
The directory of registration is defined in the document options.
But no blocks are recorded...
Could someone please give me a lead? thank you in advance
Fred