AnsweredAssumed Answered

Macro Help: Multibody part to assembly, then assembly to STL

Question asked by Greg Shulman on Aug 29, 2016
Latest reply on Aug 30, 2016 by Greg Shulman

Hi everyone!


I'm new to the world of writing macros. I'm learning VBA specifically so that I can address what I feel is an unnecessary pain point at work (though I'm sure once I get into the swing of things I'll have plenty more ideas of new uses).


Here's the background:

We structure a good number of our CAD projects at my work as multibody solids, consisting of injection molded substrates and various overmolds. We prototype these parts during development with a multi-material Objet printer. In order to print our substrate and overmolded parts as a single piece with different printed materials, each solid body in the model must be saved as a separate part file, then all parts added into an assembly with origins all coincident. The assembly is then saved as .STL. These steps allow each body to be assigned a separate material in the Objet loading software, as well as giving them all the same origin so they print together, rather than separate parts on the tray. Doing this manually for parts with 5+ separate part bodies, this is time consuming and a pain, especially when we're going through lots of CAD iterations early in development.


Here are the things that I want to accomplish with a macro:

1. Prompt user to select a location to dump all saved files.

2. Save all solid bodies in the active part file as separate part files located in selected dump folder

3. Create new assembly with all saved part bodies, with all major planes aligned

4. Save new assembly in selected dump folder

5. Save new assembly as .STL in selected dump folder (save all components of assembly as separate files)


I know this is probably a fairly lofty goal for a first run at Solidworks VBA, but necessity is the mother of invention, right? Even so, I'd welcome any help anyone can offer. Does anyone have any suggestions of code that I could start piecing together, or perhaps strategy recommendations?