Recording Custom Macros and Assigning Shortcuts in SOLIDWORKS

Article by Scott Durksen, CSWE updated July 16, 2012

Article

Recording custom macros in SOLIDWORKS doesn’t always require extensive knowledge of the programming language.  Just like Excel, you can auto-generate the Microsoft Visual Basic code by using the macro recording tool.  The Macro flyout in the Tools menu gives you access to this recorder.  Click “Record” and a macro toolbar will open indicating you are recording.  Any mouse clicks, menu selections and keystrokes will be recorded.

Record SOLIDWORKS Macro

Record SOLIDWORKS Macro

In this example, I’ve preselected two faces.  When you select edges or faces while recording a macro it saves the “click” as a specific location in the model space.  Therefore preselecting the faces before running the macro gives you greater flexibility as you can use the macro on many different faces or components, as long as you preselect the items before running the macro again in the future.

This is a very simple coincident mate macro.  After clicking “Record”, I’ve selected Mates and added a coincident mate.  Then press the Stop button to finish the recording.

Stop Macro

Stop Macro

You can then save the macro file (.swp extension) to your computer.  Running the macro can be accomplished through the Tools > Macro menu but since macros are created for time-savings, the faster approach is to assign a keyboard shortcut or mouse gesture for quick access.  In SOLIDWORKS 2011 and prior, assigning keyboard shortcuts required the macro files to be stored in a “Macros” folder in the SolidWorks installation directory.  Starting in SOLIDWORKS 2012, you can now keep your shortcuts anywhere on your computer.

To assign the shortcuts, go to Tools > Customize and select the Keyboard or Mouse Gestures tab.  Choose “Macros” from the Category drop-down.

New Macro button

New Macro button

Then browse for a New Macro Button.  Add the location, click in the Shortcut column beside your custom macro and enter a shortcut.

Now with this macro, you can preselect two faces, press the keyboard shortcut and a coincident mate is instantly added.

Related Links

Get Certified SOLIDWORKS Services from Javelin

Javelin Experts can help you to:

Find Related Content by TAG:

Scott Durksen, CSWE

Scott is a SOLIDWORKS Elite Applications Engineer and is based in our Dartmouth, Nova Scotia office.