I'm currently creating macro buttons to insert blocks into the background of a drawing.
So far nothing complicated, I have a code that works very well:
Set swApp = _ Application.SldWorks
Set Part = swApp.ActiveDoc Part.EditTemplate Part.EditSketch Dim myBlockDefinition As Object Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromFile(Nothing, "D:\_MAIA\1_MODELES\4_BLOCS-BUFFERS\Tol ISO2768 - EN22768 - mK.SLDBLK", False, 1, 0) Part.EditSheet Part.EditSketch End Sub
My problem concerns the position of the block on the drawing, I would like to be able to predefine a position in my code (in X and Y).
Currently, when I launch the macro, the block fits into the bottom left corner of the drawing.
I tried a lot of things but without success.
If anyone knows anything about VBA I'm interested ;-)
So before inserting your block, you will have to create and name your insertion point that you will use instead of your "nothing", see this link to create the point:
Dim myBlockDefinition As Object Set myBlockDefinition = Part.SketchManager.MakeSketchBlockFromFile(Nothing, "D:\_MAIA\1_MODELES\4_BLOCS-BUFFERS\Tol ISO2768 - EN22768 - mK.SLDBLK", False, 1, 0) Part.EditSheet Part.EditSketch Part.ClearSelection2 True End Sub