US$0.00
0

SOLIDWORKS Macro to Programmatically Insert a Block into SolidWorks Drawing

Description

A one-line function call to programmatically insert a block into SolidWorks drawing allows you to quickly place a block in the active document. This macro returns the SketchBlockInstance for the inserted block, enabling users to efficiently place and manage sketch blocks within a drawing. It is particularly useful for automating the placement of standardized blocks, reducing repetitive tasks.

Programmatically Insert a Block into SolidWorks Drawing and A side-by-side comparison labeled "BEFORE" and "AFTER" showing a blank engineering drawing sheet with a standard border and grid labels (1 to 4 horizontally, D to F vertically). The "BEFORE" section is completely empty except for a small cursor icon near the bottom center. The "AFTER" section shows the same sheet with the addition of a blue text label "TEST BLOCK" centered horizontally and vertically in the middle of the sheet. Both sections have a small cursor icon near the bottom, indicating user interaction. The change demonstrates the insertion of a test block or note onto the drawing.

System Requirements

  • SolidWorks Version: SolidWorks 2014 or newer
  • Operating System: Windows 7 or later

Pre-Conditions

  • The active document must be a drawing file.
  • The block file to be inserted must exist in the specified path.

Results

  • The block will be inserted at the specified X and Y coordinates.
  • The macro returns a SketchBlockInstance object for the inserted block.

VBA Macro Code

Macro

You can download the macro from here.

Customization

Need to modify the macro to meet specific requirements or integrate it with other processes? We provide custom macro development tailored to your needs. Contact us

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop
    ×