Macro Library for SOLIDWORKS Automation

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.

Best practices for organizing macro library

MyToolbar is a free and open-source 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
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.


Categories

Performance

Boosting operational performance of SOLIDWORKS documents and application

Open Document In Quick View Mode From File Explorer

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

Suspend Rebuild Operation

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

Notify Long Running Command Completion

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


Import/Export

Automation of importing and exporting SOLIDWORKS files to different formats

Export Files

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

Export Part Or Component To STL

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

Batch Export To Pdf

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


Model

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

Update XYZ Curve From File

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

Delete Feature Folder With All Children Features

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

Rename All Features Sequentially

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

Suppress Features In New Configurations

Macro create new configurations for all features selected in the feature tree and suppresses them one by one in the respective configuration using SOLIDWORKS API

Write Data From Excel Table Into General Table

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

Export Table To CSV

Macro exports selected table (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

Find-Replace Text In Dimension Names

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

Create Configuration With Average Dimension Values

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

Select Features By Type

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

Delete All Equations

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

Automatically Run Macro On Rebuild

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

Automatically Run Macro On Model Load

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

Set Title To Next Part Number

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

Export To IFC (2x3 and 4)

Example in VBA to export active part or assembly document to IFC format (2x3 or 4) using SOLIDWORKS API

Display Callouts With Diameters For All Selected Circular Edges

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

Run Macro On Document Load

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


Part

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

Rename Features Based On Type Names

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

Defeature Part

Macro to convert all features in part to dumb solids (defeature part) and surfaces using SOLIDWORKS API

Rename Cut List Features

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

Exclude Selected Bodies From Cut-Lists

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

Link Cut-List Custom Properties To File Custom Properties

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

Remove All Colors From Part

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

Create Precise Bounding Box

Macro creates a precise bounding box in the part document using SOLIDWORKS API

Part Geometry Diff

Diff tool to find the geometrical difference between multi-bodies parts using SOLIDWORKS API


Developers

Helpful utilities for developers building software utilizing SOLIDWORKS API

Identify Feature Definition And Specific Type

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

Capture SOLIDWORKS Commands

Macro allows capturing SOLIDWORKS and user commands into the list box


Materials

Automation of SOLIDWORKS materials database and properties in parts

Copy Custom Property From Material To Model

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


Drawing

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

Update Referenced Configuration From BOM Tables

Macro will update the referenced configurations for all Bill of Materials (BOM) tables on the active drawing document using SOLIDWORKS API

Rename Drawing Sheets With Custom Properties Values

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

Change Layer For Selected Objects In Drawing

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

Increment The Numeric Value In The Note

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


Assembly

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

Export Components Positions

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

Copy Component Name To Component Reference

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

Break All External References For Components

Example will break all external references for all components in the active assembly using SOLIDWORKS API

Move To Folder

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

Advanced Selections

Macro adds additional selection criteria to the advanced selection tool allowing to select components which are excluded from bom, envelope, float etc.

Components Configurations Permutation

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

Show Selected Assembly Component In The Window Folder

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

Copy Component Path

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

Count All Selected Components

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

Replace Components

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

Move Suppressed Mates Into A Folder

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


Sketch

Automation of SOLIDWORKS sketch, segments and relations

Import Points Cloud From CSV File Into Sketch

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

Hide All Sketches

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

Merge Sketches

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

Create Sketch Points On Selected Edge

Macro creates specified number of sketch points on the selected edge in the 3D sketch


Security

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

Add Watermark Feature

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


Options

SOLIDWORKS document and system option automation

Export All Document Options To Excel

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


Geometry

SOLIDWORKS geometry automation: custom features, topology optimization

Split Body By Faces

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

Create Selectable Bounding Box

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


Custom Properties

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

Sort Custom Properties

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

Copy File Specific Custom Properties To Configuration Properties

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

Rename Configurations Based On Custom Property

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


Motion Study

Automation of SOLIDWORKS Motion Study module

Animate Configurations

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


Frame

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

Close All Documents Except Active

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

Run Group Of Macros

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

Load/Unload Add-In

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

Save All Documents Silently

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


© 2019. All rights reserved.
Terms Of UsePrivacyCookies