Assign a Button to a Macro in SolidWorks.

Assign a Button to a Macro

Learn how to assign a macro to a button and place that button in the Heads-up section.

Hamed Ashrafi
Hamed Ashrafi

We all love the macros. They are fantastic automation tools. To run a macro we should browse to the file and press the Run command. But what if we could make a button that would run the macro? In this blog post we will discover how to do just that. I will show how to define a macro button in the View (Heads-up) section.

Step 1: Make Sure You Can See the View (Heads-Up) in Your Screen Link to this section

By default the Heads-up section is active. This section holds the most popular commands in SolidWorks. Some of the defaults that are listed here are: Zoom to Fit, Previous View and more. But if you can’t see it follow these steps.

  1. Next to SolidWorks logo open the View menu.
  2. Towards the end of the list find the view (Heads-up) and make sure it is checked.
picture of Activate heads-up section

Step 2: Open the Customize Window Link to this section

Since we are going to edit the Macro command in SolidWorks. We should access it through the Customize ... window.

  1. Next to SolidWorks logo open the Tools menu.
  2. Find the Customize ... item from the bottom of the menu list. This opens up the Customize window.
picture of open the customize window

Step 3: Locate the New Macro Button in the List of Macro Commands Link to this section

Now we have the Customize window open. We can see the list of commands that each category provides.

  1. Activate the Commands tab
  2. Find the Macro on the list of categories.
  3. On the right hand side find the New Macro Button
picture of locate the new macro button

Step 4: Drag the New Macro Button to the View (Heads-Up) Section Link to this section

The New Macro Button is a template for the button. We need to drag it to the Heads-up section. Once you let go of the mouse button a new window will pop-up. We define the macro properties in this window.

picture of drag the macro button

Step 5: Customize Macro Button Link to this section

In the previous steps we accessed the Customize Macro Button window. It is time to assign the macro to the button.

  1. Click on the ... button next to the Macro:. This will open another window to browse to the actual macro file. Notice that you can only select .swp or .dll files.

  2. From the Method: drop down list select the method that is defined in the macro. Each .swp file can have multiple methods. This drop down let us select one of those methods. If the macro has only one method defined you will have one option to choose.

  3. Under the Appearance group select the Choose Image ... button. A new window pops up to browse to a .bmp file. The image you provide will change the default button. picture of customize the macro button picture of customize the macro button with icon defined

  4. Type in the tooltip for your button. When you hover over the button a pop up shows the tooltip and a prompt. It is useful to show some information about a command to the user.

  5. Once you are happy with the setup click ok. And do the same on the Customize window.

The icon has to be in the .bmp format. To convert an image to .bmp open it in Paint and save the file as .bmp.

Final Result Link to this section

Below you can see a screen shot of the final result. In this blog post I showed you how to assign a button to a macro in SolidWorks. This should help you to access your favorite macros much faster.

picture of macro-button-result