After testing this thorougly in Fusion with python code I can't the new combined body to end up anywhere but in the RootComponent. This has to be a bug or some functionality hidden to us.
Maybe @BrianEkins or @marshaltu knows the answer?
The code in my run method would be
app = adsk.core.Application.get()
ui = app.userInterface
componentSel = ui.selectEntity('Select a body', 'Occurrences')
occ = componentSel.entity
design = adsk.fusion.Design.cast(app.activeProduct)
if not design:
ui.messageBox('No active Fusion 360 design', 'No Design')
return
comp = design.rootComponent
targetBody = comp.bRepBodies.itemByName("Body1")
toolBody = comp.bRepBodies.itemByName("Body2")
toolBodies = adsk.core.ObjectCollection.create()
toolBodies.add(toolBody)
combinedBody = fuseComponents(occ.component, targetBody, toolBodies)
And in my fuseComponents method
def fuseComponents (component, targetBody, toolBodies):
newBody = adsk.fusion.BRepBody.cast(None)
features = adsk.fusion.Features.cast(None)
features = component.features
combineFeatures = features.combineFeatures
combineFeatureInput = combineFeatures.createInput(targetBody, toolBodies)
combineFeatureInput.isKeepToolBodies = False
combineFeatureInput.isNewComponent = True
combineFeatureInput.operation = adsk.fusion.FeatureOperations.JoinFeatureOperation
combineFeature = combineFeatures.add(combineFeatureInput)
bodies = combineFeature.bodies
newBody = bodies.item(0)
newBody.name = "The new One!"
return newBody
I am sorry I can't help you any further.
- Erik