I have written a macro that goes through a BOM and saves DXF files for each item. It works fine for component parts, but if I have a weldment that is expanded to show each body as a line item, I'm having trouble. I finally found a way to get it to work, but it is horribly inefficient, and the macro takes forever to run. Hopefully someone here has a better way of doing it.
Here is my current process when the row is pointed to a cut list body (There is too much code to post it all here...):
-Select first row of BOM and open the component file
-Step through the part features to find the Cut List folders
-Add a temporary Cut List property that numbers each folder
-Going back to the BOM, I add a temporary column that ties to the new Cut List property (This gives me a unique value for each BOM item)
-I then grab the Temp value in the currently selected BOM row
-I go back to the part file and traverse the features again to find the Cut List folder with the corresponding Temp value
-I can now get the first body in the folder and do my DXF processing
-I finally go back through the part file to remove the Temp property that was added
-Once I'm done with the first row, I go to the next row and start the whole process again.
As you can see, I traverse the entire feature tree of my part file three times for EVERY row of my BOM. I'm thinking maybe I could save the bodies in an array, which should let drop to one feature traversal at the start of the macro, and another at the end, but I'm hoping there is an even better way of doing this that I have missed.
SolidworksApi macros