Hide Table of Contents

Using the SolidWorks COM Non-Attributed Add-in Wizard to Create a C++/CLI Add-in

This topic describes how to use the SolidWorks COM Non-Attributed Add-in Wizard to create Visual C++/CLI add-ins in Microsoft Visual Studio .NET 2005 or later.


  • The SolidWorks COM Non-Attributed Add-in Wizard is included in the SolidWorks API SDK.
  • The Visual C++/CLI Add-in allows the use of MFC objects.

Creating a Visual C++/CLI Add-in Using the SolidWorks COM Non-Attributed Add-in Wizard

  1. Click Start > Programs > Microsoft Visual Studio version_number > Microsoft Visual Studio version_number.

  2. Click the New Project button.

    1. Select Visual C++ > SolidWorks COM Non-Attributed Addin from the templates list. 

    2. Enter the name of your project in Name.

    3. Enter the directory of your project in Location.

    4. Click OK.

  3. Type the name of your add-in in Short name. The other fields are automatically filled in using this name.

  4. Click Options.

    1. Under Threading, select the threading option for the project.

    2. Under Interface, select whether or not to add the oleautomation attribute to your code by selecting Automation Compatible.

  5. Click SwOptions.

    1. Under AddinEvents, select the events for which you want to listen:  

      • SolidWorks Events. Fired by the SolidWorks application.

      • Part Events. Fired by individual part documents.

      • Assembly Events. Fired by individual assembly documents.

      • Drawing Events. Fired by individual drawing documents.

      • Model View Events. Fired by individual model views in each document.

It is recommended that you leave the SolidWorks Events check box selected because:

    • This check box must be selected to listen to any of the other events.

    • You can use this event's code as sample code if you decide to include event handling in the future.  

Model views are created in individual documents. To listen for a model view event, you must be listening to the basic document. Thus, the Model View Events check box is not available until you select at least one of these check boxes: Part Events, Assembly Events, or Drawing Events.

    1. Under Addin User Interface, select Create Property Page to include an add-in PropertyManager page. This page is displayed in the SolidWorks application and should contain controls to extend the add-in's user interface.  

  1. Click Finish.

Wait for the SolidWorks COM Non-Attributed Addin Wizard to customize your add-in and set up the project.

Back to top

Examining Visual C++/CLI Add-In Files Created by the SolidWorks COM Non-Attributed Add-in Wizard


C++ Add-in File






This file contains the information that automatically registers your
add-in with SolidWorks when it is compiled. You can change Name
and Description to better indicate the purpose of your add-in.

NOTE: SwAddinn.rgs is the generic name for this file. The letter n
is automatically inserted and incremented by the wizard to make the project files unique.


BitmapHandler.cpp and corresponding .h file


Images for COM add-ins (toolbars, bitmap buttons, and so on) are bitmaps stored in the DLL as resources. To use any of these images with SolidWorks, you must retrieve the image and save it to a file. You can then pass the path to the file as an argument to the methods that use the image. The BitmapHandler object facilitates this effort.

To use the BitmapHandler object, call CreateFileFromResourceBitmap
and pass it the resource name of the image you want to retrieve. The function creates the file in the system's temporary folder and returns the full path. If you then pass this path to a method, SolidWorks can load the image.


CSwAddinnDialog.cpp and corresponding .h file


This file is included to demonstrate compatibility with MFC.


DocView.cpp and corresponding .h file


This file contains the definition of the DocView object. If an add-in
is listening for ModelView events, then there is a DocView instance for
each open ModelView.


PMPageHandler.cpp and corresponding .h file


This file contains the class that implements the IPropertyManagerPage2Handlern interface. An instance of this object is passed to SolidWorks when creating a PropertyManager page. When a control on the page is manipulated, the corresponding function in this object is called.


stdafx.cpp and corresponding .h file


This file contains the #import statements for the SolidWorks type libraries and any other necessary SolidWorks #include statements.

Because a PropertySheet member exists in the VC7 libraries, IModelDoc2::PropertySheet was redefined to IModelDoc2::SwPropertySheet in the #import statement for sldworks.tlb.


SwAddinn.cpp and corresponding .h file


This is the main add-in file. It contains the implementation of the
ISwAddin interface.

ISwAddin::ConnectToSw and ISwAddin::DisconnectFromSw are the entry and exit functions for this add-in. This file also contains the user interface and SolidWorks event callback functions.

NOTE: SwAddinn.cpp is the generic name for this file. The letter n
is automatically inserted and incremented by the wizard to make the project files unique.




This file declares DLL function exports.




This file is used to generate the type library for the add-in.




Generated by Visual Studio, this file contains COM definitions for the DLL.


SwDocument.cpp and corresponding .h file


This file contains the CSwDocument class that handles events thrown
by open model documents. There is an instance of this class for every
open model document.


UserPropertyManagerPage.cpp and corresponding .h file


This file contains the wrapper class for the SolidWorks IPropertyManagerPage2. A PropertyManager page allows you to extend the user interface for your add-in with standard buttons, check boxes, and so on.

The function AddControls controls the layout of the PropertyManager
page. All controls must be added to group boxes on the page. Group boxes are displayed in the order in which they are added. Controls in a group box are displayed in the order in which they are added to the group box.

Back to top

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

Subject:   Feedback on Help Topics
Page:   Using the SolidWorks COM Non-Attributed Add-in Wizard to Create a C++/CLI Add-in
*   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:


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

Web Help Content Version: API Help (English only) 2013 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.