Have you ever looked at a part in SOLIDWORKS and wondered what kind of geometry was used for a specific face? If it’s someone else’s part or you imported it, it can be difficult to know what geometry makes up the body. Knowing this information can be helpful for many reasons – like troubleshooting errors and warnings from creating new features or generating g-code for CAM applications. In particular, it can be good to know whether the geometry is an ‘analytic/algebraic’ type (planes, cylinders, spheres, cones and tori) or a spline type.
There is a huge amount of capability available to the user from the SOLIDWORKS APIs. Basically, most everything we have available in the graphic user interface (GUI) is also available through the API interface… Rather than trying to spend a lot of time up front trying to understand everything about programming and COM, the intent of this article is to jump head first into the shallow pool by showing the steps to write a simple macro using Visual Basic for Applications (VBA).
There is nothing more frustrating than running into an error message in the process of writing or running a macro and not knowing what the issue is or how to even start fixing it. Hopefully this post will demystify the errors a bit and get you pointed in the right direction to solve the problem.
The Help File for the SolidWorks API (found under Help -> API Help) is a very convenient and useful resource when it comes to working your way through writing a macro. Not only does the Help File provide helpful information about specific components within the API, its organization also provides us with a lot of insight into the SolidWorks Object Model that we’ve been discussing.
In the previous post, we discussed the SolidWorks Object Model and how its hierarchical structure impacts the way you access API functionality. But how do you find what you need within the hundreds of interfaces and functions within the API? Fortunately, you don’t need to know all – or even most – of the API in order to start doing useful things. Here are some commonly used interfaces and functions that will get you up and running: