The API for SOLIDWORKS and PDM can provide a huge number of optional benefits. This is a Q&A-style article intended to walk the average person through an otherwise broad and complicated topic. I’ll start from the beginning by explaining what it is and provide some examples. Then move through to best use cases and suggestions for refining your need into a program. If you need further help or suggestions, we have an experienced development team dedicated to creating custom applications for our customers.
The SOLIDWORKS API, or Application Programming Interface, allows the automation of repetitive and tedious tasks within SOLIDWORKS. Custom applications using the SOLIDWORKS API can be as simple or as complex as desired, for instance, the API can be used to create simple macros. Macros, at their core, are just a preprogrammed sequence of events. Sequences of mouse clicks can be recorded and automatically inserted into a new macro by using the SOLIDWORKS macro recorder. Simply start the recorder, and then perform the set of actions you’d like repeated. That will produce a very simple VBA macro that can be replayed at any time.
More functionality can then be added to a macro by editing it in the built-in VBA macro editor. All sorts of items can be added, including logic and intelligence, prompts to the user to send warnings and other information, or to gather user input and selections.
SOLIDWORKS Standard, Professional, and Premium all come with the ability to use, create, and modify macros.
It is also possible to create more complex applications by using C#, VB.net, or C++. These programming languages can be used to create custom add-ins and stand-alone applications that can launch and run SOLIDWORKS without a user’s interaction. See below for an example of a custom SOLIDWORKS add-in.
The API can be used for anything that can save a designer time. It can also be used to accomplish tasks that normally could not be done by SOLIDWORKS. Such as inserting a user coordinate system at a specified X, Y, Z location or setting a file to automatically perform additional actions whenever the model is rebuilt, such as updating a general table. Other interesting ideas are adding a watermark or some visible label to a part model that cannot be deleted or removed. BOM tables can be exported to CSV or Excel. Custom properties can be populated from an Excel spreadsheet. And the list goes on.
It is important to note that SOLIDWORKS macros are based on VBA. This is the same language used by Excel. So, if you have ever made an Excel macro, the concept is the same in SOLIDWORKS. The main difference is that SOLIDWORKS has its own set of API calls (contained within a VBA reference library) that are used to interact with SOLIDWORKS, just as Excel has its own set of calls for interacting with spreadsheets.
Creating your program as an add-in instead of a macro can provide several benefits. For instance, they can be more stable, run faster, and be more reliably updated for new releases of SOLIDWORKS. Also, some things just work better as an add-in. The downside for many is that they take more programming experience to create, and the upfront effort is greater.
The best use cases for creating an application using the SOLIDWORKS API are:
SOLIDWORKS PDM has its own API, and it’s just as powerful as the SOLIDWORKS API. The main difference is that there are no PDM macros. There are only add-ins and stand-alone applications. This means it must be programmed using C#, VB.net, or C++ (no VBA).
Since PDM is focused on file management, references, and tracking data, most custom applications for PDM also focus on those areas. They can manage file references, check things in and out of the vault, send custom notifications, and manipulate data card properties (and much more).
Another great thing, is that custom tasks can be set up for users to run on-demand or can trigger automatically on workflow transition (hopefully you are familiar with PDM workflows?).
Some add-ins are what I call ‘hybrid’ add-ins. These are add-ins in PDM that are designed to utilize both the PDM and SOLIDWORKS APIs. With these, PDM can automatically open files in SOLIDWORKS and perform specific actions. It can use the information in PDM to determine which files to process. Information PDM can use includes bills of materials, where used lists, file references, and data card variables.
Planning out your custom application is one of the most important steps – aside from actually getting it working! First, describe what you want this program to do and write it down. Writing it down will force you to actually define it as opposed to just having an idea in your head that can change over time. It is very important to have a targeted goal in mind, even for the simplest of macros.
Next, build an outline. You can skip this step if you are just building something quickly or if it’s only for yourself. Overall, it’s a little bit like writing a paper. Pick a topic, write a summary, and then outline what the program should do. Write down step-by-step what the application will do. This will also help when a year from now you’re trying to remember what this thing does.
Here is an example:
Summary: A SOLIDWORKS Add-in, that, on the click of a button, will use the value of an existing custom property as the basis for a SQL query in a custom database. It will then use the returned string to automatically create 2 new custom properties in the currently open SOLIDWORKS part file.
Outline:
In this case, the application was designed as a SOLIDWORKS add-in and would be written in C# programming language. This would allow for better handling of the SQL query than is available using VBA macros.
As you may have noticed, something like this could also be used for ERP integration. A full solution would need to be able to push information to the SQL database instead of (or in addition to) pulling from it.
Yes! …provided it is possible. GoEngineer has an amazing team that is ready to help. Our developers have been programming custom applications for decades. We would follow the same basic process I’ve already discussed, starting with, What do you want to accomplish? Can any of it be done already with out-of-the-box functionality in SOLIDWORKS or PDM? Then we’ll help to refine your need and can get started building it for you.
The API is an amazing tool to help your designers and potentially other departments in your organization. The API is not intended to replace your designers, it is intended to increase their productivity. I usually recommend starting with one main goal for automation and then if you need more, to grow it from there. Many people try to put too much into an application at once and the scope can either grow out of control or never get finalized. It is often easier to pick a starting point, use it for a while to figure out if there are any other enhancements you would like made, and then do both the enhancements and additions at a later time.
I hope this has helped clear up what the API is and how it could benefit you. It has so much flexibility, if you are looking for more information, the online help files are available here: Welcome – 2022 – SOLIDWORKS API Help.
SOLIDWORKS PDM Professional Automated SQL Backups
Enabling the SOLIDWORKS PDM Add-in
SOLIDWORKS PDM 2025 - What's New
How to Install the SOLIDWORKS PDM Server
About GoEngineer
GoEngineer delivers software, technology, and expertise that enable companies to unlock design innovation and deliver better products faster. With more than 40 years of experience and tens of thousands of customers in high tech, medical, machine design, energy and other industries, GoEngineer provides best-in-class design solutions from SOLIDWORKS CAD, Stratasys 3D printing, Creaform & Artec 3D scanning, CAMWorks, PLM, and more
Get our wide array of technical resources delivered right to your inbox.
Unsubscribe at any time.