I need to access the child components of a component (often the root component). I need to create an object collection of all bodies in the parent and its children to edit the groups
Solved! Go to Solution.
Solved by marshaltu. Go to Solution.
Hello,
The following script would demo how to get all bodies under root. Please let us know if you have other questions.
Thanks,
Marshal
import adsk.core, adsk.fusion, traceback def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface design = adsk.fusion.Design.cast(app.activeProduct) root = design.rootComponent componentNameMap = {} componentNameMap[root.name] = root for occ in root.allOccurrences: subComp = occ.component componentNameMap[subComp.name] = subComp allbodies = adsk.core.ObjectCollection.create() for comp in list(componentNameMap.values()): for body in comp.bRepBodies: allbodies.add(body) ui.messageBox("Total {} bodies under root component".format(allbodies.count)) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
What am I supposed to do with this root? I am new to Fusion 360 and really need to see the children of a feature so I know what may change or have issues. Thanks in advance.