Hide Table of Contents

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:

  1. Implement a co-creatable object that supports SwAddin.

  2. 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.
  1. Define event handlers as needed.

In its implementation of ISwAddin::ConnectToSW, the add-in can:

  1. 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.

  2. Call ISldWorks::AddMenuItem3 and pass the callback method associated with the menu item.

  3. 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:

  1. Checks the registry for add-ins.

  2. Creates an object associated with the CLSID of the add-in.

  3. Performs a QueryInterface on the add-in looking for the SwAddin object.

  4. 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:

  1. Calls ISwAddin::DisconnectFromSW, providing the add-in an opportunity for cleanup.

  2. 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:

 

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Using SwAddin to Create a SOLIDWORKS Addin
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:




x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2018 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.