Chapter 15. Automating Tasks with the API

The SolidWorks API (application programming interface) is a simple yet powerful tool for automating almost any type of task in SolidWorks. Using macros can enhance your productivity, enabling you to do things not offered directly by SolidWorks software. Being able to create your own macros makes you worth more at your place of work, and you can use them to do almost anything that you can imagine. You can start by recording very basic macros, and develop your skills into more involved code writing with error checking and user input. You do not have to be much of a programmer to follow what I show here. I am not much of a programmer, though a basic understanding of Visual Basic is useful.

Visual Basic is a common programming language. VBA (Visual Basic for Applications) is included in SolidWorks in the same way that it is included in Word and Excel. If you have programming skills with these other common applications, those skills are largely transferable to working with SolidWorks macros.

Application Programming Interface (API) refers to the available SolidWorks functions that can be called programmatically (numbered in the hundreds), from VB, VBA, VB.NET, C++, C# (C sharp), or SolidWorks macro files that have the extension of *.swp or *.swb.

Note

The *.swb file type is a legacy macro. These files can be edited and saved ...

Get SolidWorks® Administration Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.