- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Deriving bodies to separate parts programattically
I am trying to build a script that does what the make components command does, but automates the passing of metadata from the multibody part to the individual parts. We design most of our weldments in multibody and then derive out to create an assembly that can be used for drawings and BOM's. The parameters that define the different pieces of steel (length width and thickness usually, but not always) live in the multibody part. I have a nomenclature system that links parameter names with body names, so that it is easy to know which parameter should go to which part, either manually or with a script.
So far I can either push the bodies out as base features in a script, thus losing connectivity, or derive the part into another part in a script, maintaining connectivity but unable to specify which body to choose and export programmatically. I suspect (hope?) that there is syntax in either methods or properties of the derived part definition options to add or remove individual entities to the derived part definition but I have so far been unable to either find or fake them. Below is the snippet in question. first and last line work fine, if I leave out the second line I get a derived part with all the bodies from the source part. But I cannot seem to find the structure that will get one specific body and push it to the derived part as a derived entity. (i.e. maintaining connectivity). Any advice or insight deeply appreciated.
'CodeStarts
'prior code, which all seems to work, iterates through bodies and associates them with parameters based on naming convention, and defines and creates target part
oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)
oDerivedPrtDef.Entities.Add(oBody) ' this line is totally made up and throws errors, but gives the idea of what I need.
oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)
'subsequent code saves new part with derived bits.
'Code Ends.