Macro for adding all assem parts to single drawing?
Macro for adding all assem parts to single drawing?
(OP)
Hello,
I’m a new SolidWorks user, having picked up 2006 at the end of January. This is my first post, though I’ve been lurking for a while. I’ve learned a lot from this forum, so thank you!
My question is, does anyone know of or have a macro that will take all the individual parts from an assembly and add them to a single drawing? I’ve searched this forum and a few others without luck, unless I’ve missed something.
We build large water and chemical tanks out of plastic, and our assemblies have anywhere from 50 to 200 parts, all of which have to be placed in a single drawing file. We then export a DWG to Mastercam so the parts can be nested on 48 x 120 or 60 x 120 sheet stock (no forming or molding). Right now I’m adding each part to a large 1:1 drawing individually. This turns out to be very time consuming and I’d love to speed up the process.
Hope that makes sense. If anyone has any suggestions it would be greatly appreciated.
Thanks.
I’m a new SolidWorks user, having picked up 2006 at the end of January. This is my first post, though I’ve been lurking for a while. I’ve learned a lot from this forum, so thank you!
My question is, does anyone know of or have a macro that will take all the individual parts from an assembly and add them to a single drawing? I’ve searched this forum and a few others without luck, unless I’ve missed something.
We build large water and chemical tanks out of plastic, and our assemblies have anywhere from 50 to 200 parts, all of which have to be placed in a single drawing file. We then export a DWG to Mastercam so the parts can be nested on 48 x 120 or 60 x 120 sheet stock (no forming or molding). Right now I’m adding each part to a large 1:1 drawing individually. This turns out to be very time consuming and I’d love to speed up the process.
Hope that makes sense. If anyone has any suggestions it would be greatly appreciated.
Thanks.






RE: Macro for adding all assem parts to single drawing?
I wrote similar macros for exporting sheet metal assemblies to CAM software. But I had the added advantage of creating a flat pattern view that was pretty much guaranteed to be perpendicular to the view, because of a macro API call that does this very thing for you.
Without it, you could be exporting a 2d profile of the thickness, and when doing hundreds of parts automagically, its easy to miss.
BTW, does MasterCam keep a (text ?) list of the files to nest, along with quantities, etc?
RE: Macro for adding all assem parts to single drawing?
However, I see exactly what you're saying about mistakenly exporting a 2D profile of a thickness...that would get confusing when dealing with a lot of parts. We use the sheetmetal functionality and flattened states for all our thermally bent pieces, but that's only about 1/3 of our parts. Is there a way to create a configuration that always places a part in a certain view orientation?
To my knowledge MC doesn't keep a file referencing the nested parts, but we just got Mastercam X so I may be the wrong person to ask. We've been in the stone ages up until a few months ago.
Thanks.
RE: Macro for adding all assem parts to single drawing?
All the "nesting" programs that I've read about take individual profiles (and quantities thereof) & run their algorithm(s) to determine the most efficient layout of parts. This takes into account the max' use of material while considering the min' cutting path and multiple sheets if necessary. Also parts can be "flipped" or rotated to create better fits & variable "no-go" clamping areas allowed for. To create a "macro" to compute all those conditions is not a lightweight task ... especially if some parts have unusual profiles.
I know precious little about Mastercam's "True Shape" nesting function, but it would probably be a better option than trying to develop a SW API macro.
Helpful SW websites FAQ559-520
How to get answers to your SW questions FAQ559-1091
RE: Macro for adding all assem parts to single drawing?
By parsing the assembly first, I wasnt re-exporting a drawing 20 times if a single part had 20 instances in the assembly.
Next the app started up a single new drawing, looped thru, grabbed each unique part, exported one flat pattern view at 1:1 on the drawing. It parsed the actual geometry out of the view ,exported a custom dxf (without the HEADER, BLOCK sections) , rotated the geometry for the best orthagonal fit, and shifted the geometry so the lower left was X0Y0.
Once done, it ERASED the drawing view, went back, and grabbed another part until the whole assembly was done. It also had a feature to ignore part export if the exported part file already existed. (so you dont have to redo microjoints, etc with your CAM app)
Once done that, it then wrote out the nesting files required by Fabrwin which assigned the parts and their quantities to nests depending on the material/thickness information it grabbed off of each exported part.
BTW, you dont need BENDS to have a sheet metal part. New, simple parts can be made using a BaseFlange feature, and old parts without bends can be 'converted to sheet metal' by just clicking on the "Insert Bends" feature. SWX will complain about not finding any bends, but it puts the sheet metal feature in anyway (along with the thickness value I needed for nesting). The face you click on for "Insert bends" will be the face drawn "normal" to the view once the part is "flattened" in a Flat Pattern view.
I did this for hundreds of parts a day for years, and the only problems I ever ran into were actual SWX bugs that appeared in a few certain service packs, and only if you also used part configurations.
You may want to check to make sure you arent runing one of those certain service packs...
RE: Macro for adding all assem parts to single drawing?
Your program sounds like it does exactly what I've been looking for, so that will give us a good place to start.
I appreciate yours and CorBlimeyLimey's responses.