SolidWorks API Advice for Beginners

Without the proper foundation, learning the SolidWorks API can be nothing short of frustrating. As a self-taught SolidWorks API programmer, here’s 7 pieces of advice I want to offer to help you on your learning journey. These guidelines are adapted from 7 Mistakes New SolidWorks API Programmers Make.

  1. Learn the SolidWorks API using VBA. I know, it may be tempting to use a more powerful language like VB.NET or C#, but 95% of the time is overkill. VBA macros are much faster to write and debug, which means you’ll learn the API that much faster. Later, if you decide to write add-ins or stand-alones then you can move to one of the other languages.
  2. Stop relying on the macro recorder to write code for you. The macro recorder has one purpose only in the API programmer’s toolbox: to determine names of API calls or interfaces when you’re having trouble finding them in the API Help. Other than that, the API Help is a crutch—and a pretty weak one at that. Learn to use the API Help or keep floundering.
  3. Use the API Help. The API Help is the definitive reference of the SolidWorks API, and there is no substitute. The speed at which you will write code is almost directly proportional to your skill at researching calls and interfaces in the API Help. Moreover, you should use the local API Help, not the online API Help. The former is vastly easier to search, namely using the Index tab.
  4. Understand the SolidWorks API Object Model. Everything you interact with in SolidWorks is considered an object by the SolidWorks API. If you don’t know how these objects relate to another then you’ll struggle to write macros of even mild complexity.
  5. Modularize your code. Modularization is a programming technique in which you separate code blocks into separate functions so that you can easily debug and re-use them. Sloppy programmers don’t modularize—they try to accomplish everything in one code block. Cut this corner in the short-run and you’ll pay for it in the long-run.
  6. Document and format your code properly. Like #5, if you want to avoid wasting your time in the long run then you need to have code that is formatted properly, uses meaningful variable names, and contains lots of comments explaining the purpose of each code block. If you have to return to your code 6 months later, you’ll be happy you took these steps up front.
  7. Don’t give up. Like many things in life, the SolidWorks API takes practice if you want to get good at it. You’ll hit small or large obstacles when writing even the simplest macros, but keep your eyes on the goal: automating your project, impressing your co-workers, expanding your professional repertoire, or whatever else. Stick with it and enjoy the result.

I hope this article gave you a good starting point for beginning (or continuing) your API learning journey. If you’re looking for beginner-friendly training, check out the free video tutorials and macros at

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s