Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

So, you’ve installed SOLIDWORKS CAM and you’re excited to start using it, but when you navigate to your Add-Ins tab, there’s no CAM Add-In.

To manually activate the CAM Add-In, you need to navigate to Tools > Add-Ins or use the Options drop-down and select Add-Ins.

solidworks cam add-in location

By selecting the checkbox next to SOLIDWORKS CAM and selecting OK, you will now have a new SOLIDWORKS CAM Tab on your Command Manager.

However, it would be nice to have an Icon like all the others directly on the SOLIDWORKS Add-Ins tab on your Command Manager that will load and unload the CAM Add-In. We can do this via a custom Macro button.

There are a couple steps to adding a Macro button in SOLIDWORKS and it may require that Visual Studio Tools for Applications (VSTA) is already installed on your computer. If you are familiar with SOLIDWORKS Macros and would like a direct download to the .swp file, click here.

However, to make your new Macro button from scratch;

Start Here:

Step 1: Create the Macro .swp file.

To create a new .swp file (Macro file) you’ll need to activate the Macro Toolbar by Right-Clicking on the Command Manager and selecting the Macro toolbar icon.

step 1 for creating a macro for solidworks cam

Then select the New Macro button:

create new macro button for toggling solidworks cam add-in

This will prompt you to save your .swp file. I would recommend saving this .swp file to a personalized location where you know it won’t get accidentally deleted/moved. Give it a name like CAM-Add-In.swp.

solidworks cam add-in macro to toggle save dialog

Then in the Macro Editor:

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

We want to delete everything in here and replace it with the following script, making sure you change the location of your cwaddinu.dll to the correct file path location (text in red):

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExtension As SldWorks.ModelDocExtension
Dim swAssembly As SldWorks.AssemblyDoc
Dim swModelViewManager As SldWorks.ModelViewManager
Dim response As Long
Dim status As Long
Dim tabs As Variant
Const sAddinName As String = "C:Program FilesSOLIDWORKS CorpSOLIDWORKS CAMcwaddinu.dll"
'*******************************************************************************************
'
' Written by John Milbery
'
' Macro to toggle the addin of SOLIDWORKS CAM as loaded or unloaded. The full path name of the cwaddinu.dll
' must be specifeid in the string variable sAddinName
'
'*******************************************************************************************
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swModelDocExtension = swModel.Extension
Set swModelViewManager = swModel.ModelViewManager

tabs = swModelViewManager.GetFeatureManagerTabs
nbrTabs = UBound(tabs) + 1

If nbrTabs >= 7 Then
status = swApp.UnloadAddIn(sAddinName)
End If

If nbrTabs <= 6 Then
status = swApp.LoadAddIn(sAddinName)
End If

End Sub

Once it has been copied, your Macro Editor will look something like this:

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

Save and close your Macro file.

Step 2: Create the Macro button on your Command Manager.

To add a new Macro button, you’ll need to access it via the Customize menu. To access the Customize menu, right click the empty space in the Command Manager Ribbon and select Customize.

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

Once in the Customize menu, navigate to the Commands tab, and the Macro category. In the Macro category, Drag and Drop the New Macro Button command onto the Command Manager where you want your new CAM Add-In icon to be.

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

Once you’ve placed the New Macro Button where you want it, you’ll see the following prompt. Press the indicated button and locate your previously saved .swp file.

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

Once the .swp file is loaded, you can change the Icon by pressing Choose Image. For the image to use, you can Right Click the image below and select Save image as… to save the .bmp file and load it into your Macro.

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

For the Tooltip write: SOLIDWORKS CAM

And for the Prompt write: Loads and Unloads the SOLIDWORKS CAM add-in.

Once the button is placed, it should look something like this:

, Using a Macro Button to toggle the CAM Add-In on the Add-Ins tab

And once your icon is placed, you can always move it again to wherever you’d like while in the Customize menu.

Tech Tip: If you have SOLIDWORKS CAM Professional, you can add this add-in to the Assembly level SOLIDWORKS Add-Ins tab also.

Special Thanks: To John Milbery at SOLIDWORKS for writing this macro for SOLIDWORKS CAM.

Jordan Puentes, Elite AE
Application Engineer
Computer Aided Technology, Inc.
www.cati.com

  • Share this
Find Your Design Solution in the CATI Store.
Browse Products