4 Replies Latest reply on Jun 15, 2016 11:30 AM by Steve Crago

    SolidWorks Add-In Example

    Matt Fahner

      Hi, I'm looking to get into SolidWorks Add-In programming, but am having trouble getting started.  I've tried to install the API SDK, but found that it only works with the full version of Visual Studio, where I only have Visual Studio Express.  I'm most familiar with VB.net, but have had no luck finding examples.  Does anyone have a sample they could share?  Does anyone have VS who wouldn't mind sending a copy of the template files so I can use them in VSE?

        • Re: SolidWorks Add-In Example
          Matt Fahner

          To clarify... I know there are some examples on this board, but they are all quite complex and many for PDM rather than SW itself.  I'm really just looking for something really simple to understand the basics - just a "Hello World" example really.

          • Re: SolidWorks Add-In Example
            Marshall Wilson

            So you are looking to find a way to break in to the Solidworks API in general - meaning macro programs and/or add-ins. Or are you specifically looking for Add-In examples.


            From what I understand, either way you have to tackle the Solidworks API language. Everybody always says that the best way to learn is to look at the Solidworks help files for API - but the problem is that it is a hard shell to break so to speak. From my extremely humble experience, if you have some ideas of what you want to do then you should search google "Solidworks API example" for whatever thing you want to do. The SW API is so extremely huge that to run at it without specificity of purpose is gonna cause lots of headaches. Seems to me that Learning API with SW help files is easier with VBA than VB.Net as there are more VBA examples.


            That said. I bought a book which was kinda helpful in opening the door just a crack. Can't remember what its called offhand. Search amazon for "Solidworks API macro " or something like that. It mainly featured VB.NET programs.


            One thing I did to help me break things down was to go through some of the main API Interfaces (IModelDoc2, IView, IConfigurationManager, etc) and write down in a text file some of their methods that I thought sounded pretty useful. That may at least start to understand how things get done.

            • Re: SolidWorks Add-In Example
              Keith Rice



              First, add-ins are not a good way to start learning the API, as the other gentlemen alluded to as well. I would strongly recommend that you read this:

              7 Mistakes Beginner SolidWorks API Programmers Make


              Nevertheless, let me address the issues you brought up in your original post.


              The SDK does work with Visual Studio Express editions. Attached is the VB.NET add-in that comes with the SDK, opened and saved from within Visual Basic Express Edition. A few comments:


              1. There is one notable change I made to this VB.NET project. I created a "thirdpty" folder in the solution folder and changed the project references to point to the interops in this folder, rather than the ones on my hard-drive. Otherwise you would have had missing references when you opened it on your end. Also note that I used SolidWorks 2014 references. If you're using an earlier version, replace the DLLs in the "thirdpty" folder with the equivalent DLLs within your root SolidWorks installation directory.


              2. Before you run the launch the add-in from Visual Studio Express, modify this file (in the project folder) to contain the correct path to your SolidWorks executable:




              SolidWorks API Training

              • Re: SolidWorks Add-In Example
                Steve Crago

                AngelSix have done a very simple to follow tutorial for creating a SolidWorks Add-In. Have a look at  their web site http://angelsix.com/solidworks