How use addExistingComponent under a occurence that is not the top node

How use addExistingComponent under a occurence that is not the top node

seb.quevillon.1
Participant Participant
458 Views
2 Replies
Message 1 of 3

How use addExistingComponent under a occurence that is not the top node

seb.quevillon.1
Participant
Participant

Hi,

 

I would like to know how to add an existing component under a subassembly and not the top node.

 

In the example below, I would like to copy the "cube" (component ) under  "Cube_Assembly:1" (occurence).

 

example.jpg

 

I also attached the fusion file.

 

Thank you

 

0 Likes
Accepted solutions (1)
459 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

I think this should do it.

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        cubeComp = des.allComponents.itemByName('cube')
        cubeAssemblyComp = des.allComponents.itemByName('Cube_Assembly')

        occ = cubeAssemblyComp.occurrences.addExistingComponent(cubeComp, adsk.core.Matrix3D.create())
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))  
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

seb.quevillon.1
Participant
Participant

Thank you !

0 Likes