SOLIDWORKS API
Help
Assign SOLIDWORKS Macro to Button
When you create a SOLIDWORKS macro, you can assign a bitmap to a macro
button on a SOLIDWORKS toolbar. The SOLIDWORKS software includes sample
bitmaps, or you can create your own bitmap. If you create a bitmap for
a macro button, the bitmap must meet these requirements:
To assign a macro to a button:
With a document open, click Tools
> Customize.
In the dialog box, on the Commands
tab:
Select Macro
in Categories.
Under Buttons,
drag the New Macro Button
to any toolbar or the CommandManager in SOLIDWORKS.
In the Customize
Macro Button
dialog box:
Under Appearance:
Click Choose
Image.
In the Icon
path dialog box, select a bitmap image (*.bmp),
then click Open.
NOTE: The SOLIDWORKS software provides bitmap images to use as custom
buttons. These are located in install_dir/data/user
macro icons. Select Thumbnail
to see the image in the Icon
path dialog box.
Type a Tooltip
and Prompt message, which should
provide a brief description of the function of the tool on the status
bar. Both the ToolTip and message are displayed when the pointer is on
the bitmap.
Under Action:
Click
and navigate to the
folder where the macro is stored.
In the Macro Path dialog:
Select SW
VBA Macros (*.swp) if adding a VBA macro (selected by default).
- or -
Select SW VSTA Macros (*.dll) if
adding a VB.NET or C# macro.
NOTE:
SOLIDWORKS 2018 offers Visual Studio Tools for
Applications (VSTA), impacting how you develop and run VB.NET and C#
macros in SOLIDWORKS 2018 and later.
Select the macro.
Click Open.
Select the macro that you want to assign
to the button.
Click Open.
Click OK.
Click OK
to close the Customize dialog
box.
To edit a macro button on a toolbar or CommandManager:
In an open SOLIDWORKS document, click Tools
> Customize.
If on a toolbar, right-click the macro button that you
want to edit.
-
If in CommandManager, right-click the macro button that you want to edit.
Select Properties.
In the Customize
Macro Button dialog, edit the macro button and click OK.
Click OK
to close the Customize dialog.
To delete a macro button from a toolbar or CommandManager:
In an open SOLIDWORKS document, click Tools
> Customize.
If on a toolbar, drag and drop the macro button from
the toolbar to the Recycle Bin.
-
If in CommandManager, right-click the macro button that you want to
delete. Select Delete.
Click OK
to close the Customize dialog.
For more information about assigning macros to toolbars, see SOLIDWORKS
Help.