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. Call regsvr32 during installation. Register the add-in 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.

  3. 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) 2014 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.