Hide Table of Contents

Using the SolidWorks C# Add-in Template to Create a Visual C# .NET Add-in

This topic describes how to use the SolidWorks C# Add-in Template to create a Visual C# .NET add-in in Microsoft Visual Studio .NET 2005 or later. This topic also identifies and describes the classes provided by the template. Click a link to read that section.


Creating a Visual C# .NET Add-in using the SolidWorks C# Add-in Template

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

  2. Select Tools > Options > Projects and Solutions > General > Save new projects when created.

  3. Click the New Project button or select File > New > Project.

  4. Select Visual C# > SwCSharpAddin from the templates list.

  5. Enter the name of your project in Name.

  6. Enter the location of your project in Location.

  7. Click OK.

Wait for the SolidWorks C# Add-in Template to set up your add-in's project files and to locate your SolidWorks directory.  

Back to top

Examining Visual C# .NET Add-In Classes

These classes are created by the SolidWorks C# Add-in Template:








This file provides a means to organize and publish assembly-specific information.




This file contains the event handling objects for documents and model views. The DocumentEventHandler object is a base class that exposes the interface and contains code for dealing with ModelView events.

PartEventHandler, AssemblyEventHandler, and DrawingEventHandler are the three object types that can listen for document events. There must be one instance of each class for each open document of that type.

The ModelViewEventHandler object listens for ModelView events. There should be one instance of ModelViewEventHandler for each ModelView in each open document.




This file contains the class that implements the PropertyManager page handler 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 method in this object is called.




This file contains the main add-in class. Visual Studio adds the letter n to the default name SwAddin, if more than one project by that name exists in the same location. Examine the code in each region of this file:






Local Variables


Contains the definitions of this class's variables


SolidWorks Registration


Contains methods to register and unregister the add-in


ISwAddin Implementation


Contains ISwAddin::ConnectToSW() and ISwAddin::DisconnectFromSW() which are the entry and exit points for the add-in


UI Methods


Contains methods that define how the add-in behaves within the SolidWorks application


Event Methods


Contains SolidWorks event handling methods


Event Handlers


Contains the event callbacks for the SolidWorks object


UI Callbacks


Contains methods that are called from the add-in user interface




This file contains the wrapper class and layout methods for the add-in's PropertyManager page. To modify the controls on the PropertyManager page, change the code in the AddControls() method.

Add all controls to group boxes. Group boxes are displayed top to bottom in the order in which they are added to the page. Controls are displayed top to bottom in the order in which they are added to the group box.

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

Subject:   Feedback on Help Topics
Page:   Using the SolidWorks C# Add-in Template to Create a Visual C# .NET 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.