Axis isn't created in active component

Axis isn't created in active component

SaeedHamza
Advisor Advisor
267 Views
1 Reply
Message 1 of 2

Axis isn't created in active component

SaeedHamza
Advisor
Advisor

Hi,

 

I'm trying to create an axis into an occurrence that I created.

When done manually in F360, the axis gets created inside of the activated new occurrence, but that isn't the case when doing the same thing in api, what happens is that the axis gets created in the root component although it's not activated.

So, what is going wrong here?

 

Thanks,

Saeed.

 

        occ = rootComp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        occ.component.name = 'Component'

        scale_body.moveToComponent(occ) 

        occ.activate()

        axisInput = axes.createInput()
        ref_axis = axisInput.setByTwoPoints(body_ver1, body_ver2)
        axes.add(axisInput)

Saeed Hamza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
268 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi @SaeedHamza .

 

The cause is probably that "axes" is obtained as the root component.
Also, there is no need to activate Occurrence.

        occ = rootComp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        occ.component.name = 'Component'

        scale_body.moveToComponent(occ) 

        # There is no need to activate occurrence.
        # occ.activate()

        # Get the body after moving to occurrence.
        occ_body: adsk.fusion.BRepBody = occ.component.bRepBodies[0]
        body_ver1: adsk.fusion.BRepVertex = occ_body.vertices[1]
        body_ver2: adsk.fusion.BRepVertex = occ_body.vertices[2]

        # Get occurrence.component.constructionAxes
        axes: adsk.fusion.ConstructionAxes = occ.component.constructionAxes

        # Create constructionAxis.
        axisInput: adsk.fusion.ConstructionAxisInput = axes.createInput(occ)
        axisInput.setByTwoPoints(body_ver1, body_ver2)
        ref_axis: adsk.fusion.ConstructionAxis = axes.add(axisInput)
0 Likes