Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tracking a moving body

Message 1 of 6
314 Views, 5 Replies

Tracking a moving body



I am trying to figure out if there is a way to track (preferably draw a spline of where the body is moving) a moving body. I am currently running a script that allows the body to be moved, and want to draw out the path that the body is taking. Any help or direction is appreciated



Message 2 of 6
in reply to: jmt45

What's causing the body to move?  Is the user using the Move feature or are you doing something through the API?  Is it really a body that's moving or is it an occurrence that the body is in?  It's difficult to understand what's really happening and what you want to do without more details.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 6
in reply to: ekinsb

I attached a video of my current model. the gears are rotating which is causing the links to move. I need to track that blue point on the end of the long link. What i need to try and do is create a spline of the path it is taking.

Message 4 of 6
in reply to: ekinsb



I am sorry for the multiple questions.  This is for a university project and we are new to fusion 360 and its api (but knowledgeable in python).  The image I attached shows what the hierarchy is.  Basically we need to query the xyz location of the object, either through position data or a 4x4 matrix.  I was looking for something like "root.body.itemByName" but I cant find a 'body' method.  Secondly, is there an example program that I am missing which shows this?  It seems like the example programs on the API list are all about modeling within python, but do not work back and forth between having something done already in the program and then modifying different parts of it using the API.


Thank you,


Message 5 of 6
in reply to: jmt45

Sorry for my slow reply.  I've been traveling and haven't had much time to tend the forum recently.


I started to write a description of how I would approach this but decided a sample is easier for both of us.  Below is a picture of the result.


Below is the code that I used to accomplish the creation of the curve above.  It asks you to select a vertex and then uses hard-coded values to find a specific joint in the assembly but then it changes the angle of that joint and saves the current position of the vertex in a collection and finally uses those points to create the curve.  Of course it wouldn't have to be a vertex that you track but anything that can be used to infer a position.


Here's the code and I've attached the assembly that I used.  You'll see that the joint is actually in one of the sub-assemblies and the code would actually be a bit simpler if the joint is in the root component.


import adsk.core, adsk.fusion, traceback, math
def run(context):
    ui = None
        # Boilerplate code to access Fusion 360 instance.
        app = adsk.core.Application.get()
        ui  = app.userInterface

        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        root = design.rootComponent

        # Get the joint called "Motor" in PistonAssembly:1
        # This gets the joint within the PistonAssembly component,
        # not in the context of the top-level assembly.
        pistonOcc = root.occurrences.itemByName('PistonAssembly:1')
        joint = pistonOcc.component.joints.itemByName('Motor')

        # We need the joint relative to root component so we 
        # need a proxy for the joint.
        joint = joint.createForAssemblyContext(pistonOcc)

        # Have the point to track selected.
        pointSel = ui.selectEntity('Select a vertex.', 'Vertices')
        vert = adsk.fusion.BRepVertex.cast(pointSel.entity)

        numSteps = 90
        startValue = 0
        endValue = math.pi * 2

        # This assumes the joint is a revolute joint.
        revMotion = adsk.fusion.RevoluteJointMotion.cast(joint.jointMotion)
        revMotion.rotationValue = startValue
        positions = adsk.core.ObjectCollection.create()
        for i in range(numSteps+1):
            val = startValue + ((endValue - startValue) * (i/numSteps))           
            revMotion.rotationValue = val

        sk = root.sketches.add(root.xYConstructionPlane)
        sk.sketchCurves.sketchFittedSplines.add(positions)   = 'Motion Curve'         
        if ui:



Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 6 of 6
in reply to: ekinsb



I just got it working with my system. Thank you for the help, I appreciate it. 


Justin Tranchina

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report