Did you know that you can create completely custom features that behave just like regular SolidWorks features? This is possible with macro features. Just like a standard SolidWorks feature, macro features reside in the FeatureManager tree and can do anything a standard feature can do an more. Using a macro features you can do the following:

  • Create or edit bodies
  • Perform tasks during every feature rebuild
  • Use PropertyManager pages as a user interface, complete with temporary body previews
  • Prevent tampering by disabling the ability to suppress, edit, or delete

As demonstrated in the embedded video, this all makes for a feature that looks and feels like it came right out of the box. Best of all, since the code controlling the macro feature remains in the source macro file, modifications can be made to the source code that will reflect in every instance of the macro feature. It’s just like when you update a model and the change is reflected in all drawings referencing that model.

A word of warning, however: Macro features certainly fall under the category of “advanced” functionality, and for that reason they are the topic of the very last lesson in my course. Indeed, if I would consider any part of one’s API knowledge the “crown jewel” it would be the ability to write macro features. And until now, no tutorials existed to ease the learning of this powerful aspect of the API.

In my 43 minute lesson, Lesson 7.5 in our VBA course, I walk you through the creation of a complex macro feature from beginning to end. No stone is left un-turned. To help organize the procedure for creating macro features, I break the video up into several steps:

Part A: Macro feature basics
Part B: Creating a new body
Part C: Replacing an existing body
Part D: Implementing a PropertyManager page (PMP) as a user interface
Part E: Adding additional PMP controls for the body’s dimensions
Part F: Implementing edit definition
Part G: Remembering PMP control values
Part H: Implementing temporary body previews
Part I: Spike Creator demonstration

Parts A through H cover the essentials of creating a robust macro feature without any unnecessary bells or whistles. In the last part, I present to you the final iteration of the Spike Creator macro—the basics of which we developed two lessons earlier.  Specifically, I give more detail on how the merge functionality of the Spike Creator macro feature works. Also provided on the lesson page is the source code for the second macro shown in the YouTube promo, so you can see exactly how to update custom properties or run any other code you want during rebuild.

Personally, I love that SolidWorks is so customizable, right down to the most basic building block of a model—the feature. If anyone has any cool ideas for a macro feature, I’d love to hear it. Just share in the comments below.

Keith

Want to keep up with new blog posts, videos, and macros we create each month? Sign up for our newsletter!