Mechanomy

Software for Pre-CAD systems design

Timesaving Solidworks Macros

CAD modeling involves many repeated commands, but in Solidworks these four operations were so annoying that we wrote some simple macros to automate them. Grab them from https://github.com/mechanomy/SolidworksScripts, being sure to add them to your macro file locations and mapping them to shortcut keys.

addAxesXYZ

When you make a new part or assembly, or load a part from a vendor, it frequently lacks axes aligned to the part's x,y,z coordinate system. In the case of a screw or bolt, having an axial axis makes mating just a bit more straightforward. This macro adds these canonical x,y,z axes to the open part/assembly at the intersections of the canonical planes.

export3mfStep

As 3D printing often requires multiple part iterations, this macro saves the current part in 3MF and STEP files. 3mf is a hands-down better format than STL and is accepted by all(?) modern slicers. The macro also saves the model as a STEP file as a way of noting the state of the model at the print time.

importProperties2Part

As Solidworks' Excel-based Design Tables are pretty poorly designed and implemented, this macro allows these to be avoided by directly importing variable names and values from a CSV file into the current part model. With this macro you can keep shared dimensions in a common, master file which is imported by all of the parts that need those dimensions. Any changes in the master file can be propagated to the parts by simply re-importing the file.

The CSV format is:

Optional reference path to file.csv or other comment, this first line is skipped when importing.
Default; secretText; text;  secret text string;
Default; bigLength; double; 60.00000;
specialConfig; configNum; double; 2.500000;
specialConfig; configText; text; specialest config;

The second column is the property name, the third is 'text' or 'double', and the fourth the property value. In the first column, 'Default' imports the 'secretText' property with value 'secret text string' as a Custom File Property, while 'specialConfig' or any other name creates a configuration with that property.

exportPartProperties

This macro exports the current part's properties to partName.csv, following the same format as importProperties2Part. Together, these import and export macros enable you to avoid Excel-based design tables when making variable parts.

We'd love to hear if you find these useful, and if you have ideas for other Solidworks macros send us an email or mention @mechanomy_ on Twitter/X or LinkedIn.

— Ben Conrad