How to get rotational axis of revolute joint by API (python)

How to get rotational axis of revolute joint by API (python)

Anonymous
Not applicable
571 Views
1 Reply
Message 1 of 2

How to get rotational axis of revolute joint by API (python)

Anonymous
Not applicable

I created a box, cylinder, and as-built joint (revolute). 

 

I would like to get rotational axis vector of revolute joint(as-built joint).

How can I get this vector by API?

 

 

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

liujac
Alumni
Alumni

Hi,

 

The script below demonstrates how to get axis vector from RevoluteJointMotion.

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        root = app.activeProduct.rootComponent
        joints = root.asBuiltJoints
        joint = joints[0]
        revMotion = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
        axis = revMotion.rotationAxisVector
        ui.messageBox('{}, {}, {}'.format(axis.x, axis.y, axis.z))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Thanks,

Jack