SOLIDWORKS API
Help
Using SwAddin to Create a SOLIDWORKS Add-In
You can create a SOLIDWORKS add-in using the ISwAddin
object instead of using a
SOLIDWORKS
add-in wizard.
When you use the ISwAddin object to create a SOLIDWORKS add-in, the
add-in must include some specific functionality and code. It is also important
to understand what the SOLIDWORKS software does for the add-in. Click
a link to read that section.
What does the add-in have to do?
The add-in DLL must be created as a COM Server and it must:
Implement a co-creatable object that supports
SwAddin.
During installation call:
Register the
add-in's CLSID in HKEY_LOCAL_MACHINE\SOFTWARE\SOLIDWORKS\AddIns and set
the following registry keys:
-
Default to 1 or 0, where 1 enables the add-in in the add-in
manager so that it loads when the user starts the SOLIDWORKS software.
-
Description to a text description of the add-in that is displayed
in the add-in manager.
-
Title to a text title of the description that is displayed in
the add-in manager.
Define event handlers as needed.
In its implementation of ISwAddin::ConnectToSW,
the add-in can:
Call ISldWorks::SetAddinCallbackInfo
and pass the instance handle of the add-in and the object that supports
the callback methods. The SOLIDWORKS software holds onto this object and
makes callbacks.
Call ISldWorks::AddMenuItem3
and pass the callback method associated with the menu item.
Call ISldWorks::AddToolbar4
and pass the callback method associated with the toolbar button.
Back to top
What does the SOLIDWORKS software do?
When the end-user starts the SOLIDWORKS software, it:
Checks the registry for add-ins.
Creates an object associated with the CLSID of
the add-in.
Performs a QueryInterface on the add-in looking
for the SwAddin object.
Calls ISwAddin::ConnectToSW
and passes a pointer to the SOLIDWORKS session and the add-in ID.
When the user closes the SOLIDWORKS software or disables an add-in in
the add-in Manager, the SOLIDWORKS software:
Calls ISwAddin::DisconnectFromSW,
providing the add-in an opportunity for cleanup.
Destroys the object it created with the add-in
CLSID.
If the end-user disables an add-in in the add-in manager, the SOLIDWORKS
software does not reload the next time the SOLIDWORKS software starts.
If the end-user closes the SOLIDWORKS software with an add-in enabled,
the SOLIDWORKS software reloads the add-in the next time it starts.
Back to top
To learn more about add-ins and their menu items and toolbars: