Library of macros and scripts to automate SOLIDWORKS (2024)

Request macro

SOLIDWORKS Macros Library

This page contains a library of useful macros, utilities and scripts for SOLIDWORKS engineers. Macros are grouped by categories: part assembly, drawing, performance etc.

Follow the Programming VBA and VSTA macros using SOLIDWORKS API section for guidelines of using and creating macros in SOLIDWORKS.

Cannot find the macro for you? Submit the request macro form and our team will review your request and will try to add the macro to the library.

Best practices for organizing macro library

Toolbar+ is a part a free and open-source CAD+ Toolset add-in for SOLIDWORKS which allows organize the macro library in custom toolbars integrated to SOLIDWORKS environment. Add-in also allows to manage multi-user environment by storing the configuration in the centralized location.

Custom macro buttons in the toolbar

Alternatively macro buttons can be created using native SOLIDWORKS functionality. Read Creating macro buttons in SOLIDWORKS toolbars for more information.

Explore this section to find productivity and automation tools which suit your needs.

For additional productivity add-ins visit the SOLIDWORKS Labs page.

Batch Running

in some cases it might be required to batch run macros for multiple files or folders with SOLIDWORKS files. Try Batch+ is a free stand-alone application part a free and open-source CAD+ Toolset.

Categories

  • Import/Export
  • Model
  • Frame
  • Assembly
  • Developers
  • Performance
  • Custom Properties
  • Part
  • Cut-List
  • Drawing
  • Security
  • Materials
  • Sketch
  • Geometry
  • Motion Study
  • Options

Import/Export

Automation of importing and exporting SOLIDWORKS files to different formats

Batch Export To Foreign Formats

Library of macros and scripts to automate SOLIDWORKS (3)

Console application which exports all files from the specified folder to specified foreign format (e.g. eDrawings, html, stl, jpeg, etc.) using eDrawings API, without the need to have SOLIDWORKS installed or SOLIDWORKS license

Batch Export To Pdf

Library of macros and scripts to automate SOLIDWORKS (4)

Console application which exports all files from the specified folder to PDF format using eDrawings API, without the need to have SOLIDWORKS installed or SOLIDWORKS license

Export Flat Patterns From Part Or Assembly Components

Library of macros and scripts to automate SOLIDWORKS (5)

VBA macro to export flat patterns from all components of the active assembly or active part

Export Sketch To DXF/DWG

Library of macros and scripts to automate SOLIDWORKS (6)

VBA macro to export the selected 2D sketch in SOLIDWORKS part or assembly file to the DXF or DWG file

Save Bodies To Parts

Library of macros and scripts to automate SOLIDWORKS (7)

VBA macro to save all bodies (or selected bodies) in the SOLIDWORKS part document to individual files

Export Files

Library of macros and scripts to automate SOLIDWORKS (8)

Script allows exporting of the SOLIDWORKS file into the foreign format using command line

Export Selected Bodies

Library of macros and scripts to automate SOLIDWORKS (9)

VBA macro to export only selected bodies to foreign format (e.g. 3D xml, xaml, amf, 3mf)

Export To Multiple Formats

Library of macros and scripts to automate SOLIDWORKS (10)

VBA macro to export file (or optionally all configuration or drawing sheets) to multiple formats

Export Sheets To PDF

Library of macros and scripts to automate SOLIDWORKS (11)

VBA macro to export all sheets (or selected sheets) from multi-sheets drawing to individual PDF files

Export Part Or Component To STL

Library of macros and scripts to automate SOLIDWORKS (12)

Macro exports selected assembly component or part to stl format without the need of activating the document. Macro can optionally apply transformation to the exported STL to reorient the output

Import STEP files

Library of macros and scripts to automate SOLIDWORKS (13)

VBA macro to import STEP files and save as SOLIDWORKS files using a sub-folder with the same name.

Export Part File To Parasolid

Library of macros and scripts to automate SOLIDWORKS (14)

Power Shell script to export part file to parasolid format (.xmp_bin) from command line via Document Manager API (without SOLIDWORKS)

Model

Automation of 3D Models (parts and assemblies) and 2D drawings

Display Callouts With Diameters For All Selected Circular Edges

Library of macros and scripts to automate SOLIDWORKS (15)

Macro will display the callouts with the diameter values of all selected circular edges in the 3D model

Run Macro On Document Load

Library of macros and scripts to automate SOLIDWORKS (16)

Macro runs VBA code (or another macro) automatically on file load using SOLIDWORKS API

Run Macro On Document Save

Library of macros and scripts to automate SOLIDWORKS (17)

Macro runs VBA code (or another macro) automatically on file save using SOLIDWORKS API

Run Macro On New Document Creation

Library of macros and scripts to automate SOLIDWORKS (18)

VBA macro to run other macros or code on every new document creation using SOLIDWORKS API

Set Title To Next Part Number

Library of macros and scripts to automate SOLIDWORKS (19)

VBA Macro to set title with automatically incremented number from the shared file using SOLIDWORKS API for new files

Clear Layer

Library of macros and scripts to automate SOLIDWORKS (20)

VBA macro to remove all items (annotations, sketch segments, blocks etc) from the specified layer in SOLIDWORKS document

Delete All Equations

Library of macros and scripts to automate SOLIDWORKS (21)

Macro removes all of the equations (or optionally only broken equations) in the active model (part or assembly)

Create Configuration With Average Dimension Values

Library of macros and scripts to automate SOLIDWORKS (22)

Macro will create child configuration where all the dimension will be set to average value based on the minimum and maximum values of the tolerance

Find-Replace Text In Dimension Names

Library of macros and scripts to automate SOLIDWORKS (23)

Macro replaces the text in the dimension names of the selected feature or features

Delete Empty Folders

Library of macros and scripts to automate SOLIDWORKS (24)

VBA macro deletes all empty feature folders in the SOLIDWORKS files (part or assembly)

Delete Feature Folder With All Children Features

Library of macros and scripts to automate SOLIDWORKS (25)

Macro allows to delete all of the features in the selected folder in one click using SOLIDWORKS API

Delete rolled back features

Library of macros and scripts to automate SOLIDWORKS (26)

VBA macro finds and deletes all features below the rollback bar

Rename All Features Sequentially

Library of macros and scripts to automate SOLIDWORKS (27)

Macro renames all the features in the order preserving the base names using SOLIDWORKS API

Show All Comments Text

Library of macros and scripts to automate SOLIDWORKS (28)

VBA macro to show text from comments in the active document using SOLIDWORKS API

Update XYZ Curve From File

Library of macros and scripts to automate SOLIDWORKS (29)

VBA macro which updates coordinates of the free form (through XYZ points) curve from the linked external text file

Automatically Run Macro On Model Load

Library of macros and scripts to automate SOLIDWORKS (31)

Macro feature to run VBA code on model loading using SOLIDWORKS API

Automatically Run Macro On Rebuild

Library of macros and scripts to automate SOLIDWORKS (32)

Macro allows to automatically run macros on every rebuild using the macro feature and designed binder attachment with SOLIDWORKS API

Print

Library of macros and scripts to automate SOLIDWORKS (33)

VBA macro to print SOLIDWORKS documents using the specified settings (printer name, printer range, orientation, paper size and scale)

Select Features By Type

Library of macros and scripts to automate SOLIDWORKS (34)

VBA Macro to select all features in the active SOLIDWORKS model (part, assembly or drawing) by specifying its type

Select Standard Plane Or Origin By Type

Library of macros and scripts to automate SOLIDWORKS (35)

Example demonstrates how to select standard plane (Top, Front or Right) and origin by specifying its type

Assign New File Name

Library of macros and scripts to automate SOLIDWORKS (36)

VBA macro to automatically assign new file name for the document based on the referenced drawing view or custom property using SOLIDWORKS API

Export Table To CSV

Library of macros and scripts to automate SOLIDWORKS (37)

Macro exports selected table or specified tables (BOM, General Table, Revision etc.) into CSV format allowing to export with or without header preserving the special symbols like comma (,) and new line symbol using VBA macro

Write Data From Excel Table Into General Table

Library of macros and scripts to automate SOLIDWORKS (38)

Macro will read all the data from the Excel table and import it into the new general table of the active document or update existing table using SOLIDWORKS API

Frame

Automation of SOLIDWORKS menus, toolbars, 3rd party add-ins, documents management

Load/Unload Add-In

Library of macros and scripts to automate SOLIDWORKS (39)

Macro to trigger (load/unload) the specified add-in using SOLIDWORKS API

Save All Documents Silently

Library of macros and scripts to automate SOLIDWORKS (40)

VBA macro to save all currently opened modified documents silently (without the popup messages) using SOLIDWORKS API

Close All Documents Except Active

Library of macros and scripts to automate SOLIDWORKS (41)

Closes all opened documents except of an active one using SOLIDWORKS API

Run Group Of Macros

Library of macros and scripts to automate SOLIDWORKS (42)

Macro demonstrates how to run the group of macros within one macro using SOLIDWORKS API

Assembly

Automation of SOLIDWORKS assembly documents (*.sldasm): components, mates

Collect Reference Documents

Library of macros and scripts to automate SOLIDWORKS (43)

VBA macro to collect all reference output files (e.g. DXF, PDF) from all folders into a single folder

Add Display Data Marks

Library of macros and scripts to automate SOLIDWORKS (44)

VBA macro to add display data mark for configurations used in Large assembly to be opened in Large Design Review Mode or eDrawings

Copy Component Path

Library of macros and scripts to automate SOLIDWORKS (45)

Macro copies the path of the selected components in assembly or drawing into the clipboard using SOLIDWORKS API

Count All Selected Components

Library of macros and scripts to automate SOLIDWORKS (46)

Macro counts all unique components selected in the assembly and displays the result in the commands bar

Export Components Positions

Library of macros and scripts to automate SOLIDWORKS (47)

This macro exports positions of components to an external CSV text file using SOLIDWORKS API

Remove All Mates And Fix Components

Library of macros and scripts to automate SOLIDWORKS (48)

VBA macro to remove all mates and fix all top level components in the active SOLIDWORKS assembly

Make Independent With Drawing

Library of macros and scripts to automate SOLIDWORKS (49)

VBA macro allows to make an independent copy of the selected component, update reference in assembly and copy associated drawing

Move To Folder

Library of macros and scripts to automate SOLIDWORKS (50)

Macro move the components selected in the graphics area into a new folder in the feature manager tree

Copy Component Name To Component Reference

Library of macros and scripts to automate SOLIDWORKS (51)

VBA macro to copy component name to the component reference using SOLIDWORKS with an ability to filter virtual components only

Open Components In Positions

Library of macros and scripts to automate SOLIDWORKS (52)

VBA macro to open each selected component in the assembly in the separate window in the same position they appear in the current assembly view

Components Configurations Permutation

Library of macros and scripts to automate SOLIDWORKS (53)

Macro performs a permutation for each components in the root level of the assembly using SOLIDWORKS API and saves the results as individual files

Purge Components Configurations

Library of macros and scripts to automate SOLIDWORKS (54)

VBA macro to create copies of all selected components in the assembly and purge configurations in each of them

Replace Components

Library of macros and scripts to automate SOLIDWORKS (55)

Macro demonstrates how to replace selected components in the batch preserving original selections using SOLIDWORKS API

Set Components Solving (Rigid or Flexible)

Library of macros and scripts to automate SOLIDWORKS (56)

VBA macro to batch set the rigid or flexible option for selected components in the assembly using SOLIDWORKS API

Show Selected Assembly Component In The Window Folder

Library of macros and scripts to automate SOLIDWORKS (57)

Example demonstrates how to open the folder of the selected component in the assembly in the Windows File Explorer

Find Where Used

Library of macros and scripts to automate SOLIDWORKS (58)

VBA macro to find the assemblies within active assembly which are using the selected component using SOLIDWORKS API

Write Component Quantity To Custom Property

Library of macros and scripts to automate SOLIDWORKS (59)

VBA macro which writes the total quantities of components in SOLIDWORKS assembly into custom property

Move Suppressed Mates Into A Folder

Library of macros and scripts to automate SOLIDWORKS (60)

VBA macro to move suppressed mates in assembly into feature folder using SOLIDWORKS API

Open components in LDR mode

Library of macros and scripts to automate SOLIDWORKS (61)

VBA macro to open all selected sub-assemblies and part components in the Large Design Review (LDR) mode and view only mode correspondingly

Manage All External References For Components

Library of macros and scripts to automate SOLIDWORKS (62)

Example will break, lock or unlock all external references for the file or components in the active assembly using SOLIDWORKS API

Developers

Helpful utilities for developers building software utilizing SOLIDWORKS API

Capture SOLIDWORKS Commands

Library of macros and scripts to automate SOLIDWORKS (63)

Macro allows capturing SOLIDWORKS and user commands into the list box

Identify Feature Definition And Specific Type

Library of macros and scripts to automate SOLIDWORKS (64)

Helper methods allowing to identify the definition and specific type of the selected feature via SOLIDWORKS API and reflection

Performance

Boosting operational performance of SOLIDWORKS documents and application

Notify Long Running Command Completion

Library of macros and scripts to automate SOLIDWORKS (65)

VBA macro to handle the long running commands in SOLIDWORKS (open, rebuild, suppress etc.) and beep to notify its completion

Reveal Hidden Features

Library of macros and scripts to automate SOLIDWORKS (66)

Macro finds all features which are hidden in the SOLIDWORKS model and either displays or removes them

Toggle Scroll Item Into View

Library of macros and scripts to automate SOLIDWORKS (67)

VBA macro to toggle on and off the scroll selected item into view option in SOLIDWORKS FeatureManager settings

Rebuild Model

Library of macros and scripts to automate SOLIDWORKS (68)

VBA macro to force rebuild, hide all types and show isometric view of SOLIDWORKS model

Suspend Rebuild Operation

Library of macros and scripts to automate SOLIDWORKS (69)

This macro allows to suspend rebuild operation for parts, assemblies and drawings to enhance the performance using SOLIDWORKS API

Upgrade Cosmetic Threads

Library of macros and scripts to automate SOLIDWORKS (70)

VBA macro upgrades cosmetic threads to a new (SOLIDWORKS 2020) version which allows to improve performance of the document

Open Document In Quick View Mode From File Explorer

Library of macros and scripts to automate SOLIDWORKS (71)

Tool to open SOLIDWORKS assembly or drawing in quick view (large design review) mode from the context menu in Windows file explorer

Custom Properties

Automation of SOLIDWORKS generic, configuration and cut-list custom properties

Auto Date Custom Property

Library of macros and scripts to automate SOLIDWORKS (72)

VBA macro which creates a date custom property in SOLIDWORKS file in the specified format with an option to automatically update

Copy File Specific Custom Properties To Configuration Properties

Library of macros and scripts to automate SOLIDWORKS (73)

Macro copies all the file specific properties into the properties of the active configuration

Link Custom Properties To File

Library of macros and scripts to automate SOLIDWORKS (74)

VBA macro to link and auto-update multiple SOLIDWORKS custom properties from the external CSV/Text file into configuration or file

Rename Configurations Based On Custom Property

Library of macros and scripts to automate SOLIDWORKS (75)

Macro renames all configurations of assembly or part into the value of the specified configuration specific custom property

Sort Custom Properties

Library of macros and scripts to automate SOLIDWORKS (76)

VBA macro to sort file and configuration specific custom properties (in ascending and descending order) using logical order via SOLIDWORKS API

Copy Cut-List Custom Properties To Model

Library of macros and scripts to automate SOLIDWORKS (77)

VBA macro to copy SOLIDWORKS custom properties from cut-list (sheet metal or weldment) to model or configuration

Link Cut-List Custom Properties To File Custom Properties

Library of macros and scripts to automate SOLIDWORKS (78)

Macro feature to link specified custom properties from weldment cut-lists to SOLIDWORKS file custom properties

Manage Properties In Excel

Library of macros and scripts to automate SOLIDWORKS (79)

Excel macro which allows very fast way to manage (read and write) SOLIDWORKS custom properties in a batch directly from Excel spreadsheet

Part

Automation of SOLIDWORKS part documents (*.sldprt): geometry, feature tree

Remove All Colors From Part

Library of macros and scripts to automate SOLIDWORKS (80)

Macro demonstrates how to remove all colors from the part or assembly documents on all levels (face, feature, body, model) using SOLIDWORKS API

Rename Features Based On Type Names

Library of macros and scripts to automate SOLIDWORKS (81)

VBA macro renames (translates) the features in the part feature tree using SOLIDWORKS API

Rename Flat Pattern After Cut-Lists

Library of macros and scripts to automate SOLIDWORKS (82)

VBA macro to rename sheet metal flat patterns after the corresponding cut-list feature names

Cut-List

Automation of SOLIDWORKS cut-lists in Sheet Metal and Weldment parts and drawings

Colorize Cut Lists

Library of macros and scripts to automate SOLIDWORKS (83)

SOLIDWORKS VBA macro to colorize all the cut-list item bodies (sheet metal and weldments) based on the value of the custom property

Exclude Selected Bodies From Cut-Lists

Library of macros and scripts to automate SOLIDWORKS (84)

Macro excludes the solid bodies selected from the graphics area or from the feature tree from weldment or sheet metal cut-list using SOLIDWORKS API

Rename Cut-List Bodies

Library of macros and scripts to automate SOLIDWORKS (85)

VBA macro to rename bodies within the SOLIDWORKS cut-list body folder (sheet metal or weldment) based on the predefined template (e.g. custom property value)

Rename Cut List Features

Library of macros and scripts to automate SOLIDWORKS (86)

VBA macro to rename cut list features (sheet metal and weldment) based on custom properties using SOLIDWORKS API

Split To Configurations

Library of macros and scripts to automate SOLIDWORKS (87)

VBA macro which creates individual configurations for all cut-list bodies (or unique bodies) in the active SOLIDWORKS part document for the drawing generation purpose

Drawing

Automation of SOLIDWORKS drawing documents (*.slddrw): tables, views, sheets

Change Layer For Selected Objects In Drawing

Library of macros and scripts to automate SOLIDWORKS (88)

Macro will move all selected objects in the drawing sheet to specified layer using SOLIDWORKS API

Copy File Path Of All Assembly Component Drawings

Library of macros and scripts to automate SOLIDWORKS (89)

VBA macro which copies all the referencing drawings paths of the components of the active assembly using SOLIDWORKS API

Copy Drawing View Properties

Library of macros and scripts to automate SOLIDWORKS (90)

VBA macro to copy specified custom properties from the selected or default drawing view into the drawing properties

Export Dimensions Information

Library of macros and scripts to automate SOLIDWORKS (91)

VBA macro to export dimensions information (name, position, location, zone, value, tolerance) from SOLIDWORKS drawing to the CSV file

Export Flat Patterns

Library of macros and scripts to automate SOLIDWORKS (92)

VBA macro to export flat pattern views in the drawing active sheet to DXF or DWG or other format preserving the bend notes, annotations etc. using SOLIDWORKS API

Import/Export Layers

Library of macros and scripts to automate SOLIDWORKS (93)

VBA macro imports and exports information about layers (description, color, style, thickness, visibility and will print) in the SOLIDWORKS drawings

Lock Sheet Format

Library of macros and scripts to automate SOLIDWORKS (94)

VBA macro which locks (or password protects) the sheet format editing using SOLIDWORKS API

Open Associated Drawings

Library of macros and scripts to automate SOLIDWORKS (95)

VBA macro to open the drawings associated to the component in its own window regardless of naming (with an option to open the drawing in detailing mode)

Open Drawing View Referenced Document

Library of macros and scripts to automate SOLIDWORKS (96)

VBA macro opens the document referenced by the selected drawing view in the referenced configuration and display state

Rename Flat Pattern Views With Cut-List Names

Library of macros and scripts to automate SOLIDWORKS (97)

VBA macro to rename all flat pattern views in the the active sheet after the respective cut-list names using SOLIDWORKS API

Rename Drawing Sheets With Custom Properties Values

Library of macros and scripts to automate SOLIDWORKS (98)

Macro will rename all drawings sheets using the value of the specified custom property using SOLIDWORKS API

Replace Sheet Format

Library of macros and scripts to automate SOLIDWORKS (99)

VBA macro to replace sheet formats in the drawing sheets based on the specified map

Scale Views Based On Geometry Size

Library of macros and scripts to automate SOLIDWORKS (100)

VBA macro to scale drawing views in the current sheet based on the geometry size and specified map

Find And Delete Notes

Library of macros and scripts to automate SOLIDWORKS (101)

VBA macro to find and delete notes in all SOLIDWORKS drawing sheets based on the text, regular expressions or empty values

Increment The Numeric Value In The Note

Library of macros and scripts to automate SOLIDWORKS (102)

This macro increments the numeric value of the notes by matching regular expression (e.g. incrementing the revision) using SOLIDWORKS API

Print Notes Text To File

Library of macros and scripts to automate SOLIDWORKS (103)

VBA macro to output all notes text to the text file from the SOLIDWORKS drawing file

Security

Enabling additional security and protection for the models and applications using SOLIDWORKS API

Add Watermark Feature

Library of macros and scripts to automate SOLIDWORKS (104)

Adds the watermark feature (license) with custom message and name which cannot be deleted or edited

Materials

Automation of SOLIDWORKS materials database and properties in parts

Copy Custom Property From Material To Model

Library of macros and scripts to automate SOLIDWORKS (105)

Macro demonstrates how to copy the specified custom property from the material database to the model custom property using SOLIDWORKS API and XML parsers

Sketch

Automation of SOLIDWORKS sketch, segments and relations

Import Points Cloud From CSV File Into Sketch

Library of macros and scripts to automate SOLIDWORKS (106)

Macro imports the points cloud from the specified CSV file into the active 2D or 3D Sketch using SOLIDWORKS API

Export Sketch Coordinates

Library of macros and scripts to automate SOLIDWORKS (107)

VBA macro to export coordinates of sketch points from the selected sketch with an ability to convert coordinate to user units and into the model space

Hide All Sketches

Library of macros and scripts to automate SOLIDWORKS (108)

Macro will hide (blank) or show (unblank) all sketches (2D and 3D) in the active document using SOLIDWORKS API

Merge Sketches

Library of macros and scripts to automate SOLIDWORKS (109)

VBA macro to merge selected sketches into a single 3D sketch using SOLIDWORKS API

Select Equal Arcs

Library of macros and scripts to automate SOLIDWORKS (110)

VBA macro to find and select all arcs with diameter equal to the input arc using SOLIDWORKS API

Toggle Sketch Snapping

Library of macros and scripts to automate SOLIDWORKS (111)

VBA macro to toggle on and off the sketch enable snapping option in SOLIDWORKS sketch

Geometry

SOLIDWORKS geometry automation: custom features, topology optimization

Create Selectable Bounding Box

Library of macros and scripts to automate SOLIDWORKS (112)

VBA macro which creates 3D bounding box sketch based on the SOLIDWORKS bounding box with an ability to select sketch segments

Split Body By Faces

Library of macros and scripts to automate SOLIDWORKS (113)

Macro splits the selected surface or solid body by faces creating individual sheet body for each face using SOLIDWORKS API

Copy Surfaces

Library of macros and scripts to automate SOLIDWORKS (114)

SOLIDWORKS VBA macro to copy selected faces by calling the "Surface Offset" feature with distance 0

Motion Study

Automation of SOLIDWORKS Motion Study module

Animate Configurations

Library of macros and scripts to automate SOLIDWORKS (115)

Macro demonstrates how to create an animation from configurations to represents model history or sheet metal folding

Options

SOLIDWORKS document and system option automation

Toggle white drawing background

Library of macros and scripts to automate SOLIDWORKS (116)

VBA macro to toggle a white background with another color of your choice in drawings using system settings

Export All Document Options To Excel

Library of macros and scripts to automate SOLIDWORKS (117)

Macro allows to export all document properties into excel format using SOLIDWORKS API and reflection

Set Shaded Image quality to coarse

Library of macros and scripts to automate SOLIDWORKS (118)

SolidWorks VBA Macro to set the Shaded Image quality to coarse in Part and Assembly files. Also the checkmark "Apply to all referenced part documents" is set to ON if the active document is an assembly.

Library of macros and scripts to automate SOLIDWORKS (2024)
Top Articles
Latest Posts
Recommended Articles
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 6131

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.