Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Diving motion links to extract transfer function from model

martin.lab
Explorer

Diving motion links to extract transfer function from model

martin.lab
Explorer
Explorer

Hi, 

Thank you for your great work, I really appreciate the tool.

I am working on a model where an electric motor drives an input gear that transmits the motion through other gears and a peg and slot mechanism. This is built as a chain of Motion Links in Fusion360. I am trying to extract the transfer function (input rotation to output rotation of the end effector) of the system to have precise control of the motion with my motor controller (in the physical world). Through the python scripted API, I successfully rotated the input component directly or modified the joint angle through a Parameter, but the motion is not being transmitted, so I think that I really need to drive the Motion Link.

I saw a post indicating that motion links are not accessible through the API. If that is still the case (I can't find Motion Links in the API), would there be another way to do this? If I can't drive the motion link through scripting, maybe I could catch events or capture the output joint angle at regular time steps when playing the motion link animation? There might be other ways that I'm not aware of... Some guidance would be much appreciated. 

 

thank you very much for your help, 

Martin L.

 

0 Likes
Reply
Accepted solutions (1)
736 Views
5 Replies
Replies (5)

BrianEkins
Mentor
Mentor

It's possible to do what you need.  Attached is a very simple assembly with some motion links and one of the joints has been renamed "Drive".  It's a revolute type of joint.  The code below finds that joint and drives its value.  You can see the other parts move because of the motion joints applied.  You could also be querying the position of the other parts to determine the impact of setting the value has made.

def run(context):
    app = adsk.core.Application.get()
    ui = app.userInterface
    try:
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent

        driveJoint = root.joints.itemByName('Drive')
        revMotion = adsk.fusion.RevoluteJointMotion.cast(driveJoint.jointMotion)

        for step in range(360):
            angle = (math.pi / 90) * step
            revMotion.rotationValue = angle
            app.activeViewport.refresh()
    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

martin.lab
Explorer
Explorer

Hi Brian, 

 

Thank you so much for your answer! This is working wonderfully well on your example project and on test project of mine too. Unfortunately, I can't get it too work on the full assembly. I'm attaching a capture of the hierarchy. I verified that the root.name matches ("Upper Assembly v1") unfortunately, root.joints.size() is 0 and so root.joints.itemByName('Rev5') doesn't work. I'm not sure how that's possible. How else could the joints be found?

 

thank you very much, 

Martin L.

0 Likes

BrianEkins
Mentor
Mentor

It's hard to tell what's going on just from the picture.  Since it's not working there must be something else that's not so obvious.  Is it possible for you to send me your design so I can take a closer look?   My email is in my signature.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

BrianEkins
Mentor
Mentor
Accepted solution

Internally there's a difference between joints that are created using the "Joint" command and the "As-built Joint" command.  Unfortunately, they're not displayed any differently in the browser so it's easy to forget how each one was created and what type of joint they really are.  In the API they are distinctly different and to get as-built joints you use a different collection.  I just changed the following line in my program and then it works with your model.

driveJoint = root.asBuiltJoints.itemByName('Rev5')

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes

martin.lab
Explorer
Explorer

Thank you Brian! That did it, much appreciated!

0 Likes