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: 

Getting the right position and rotation of an occurrence

Message 1 of 4
305 Views, 3 Replies

Getting the right position and rotation of an occurrence

I have a similar problem as this one:

"Background: I'm working on a script that will let me export STLs for all the unique components in my Fusion 360 assembly along with a JSON file containing the position and rotation data info for all the occurrences (aka occurrence.transform.asArray()) .  I ultimately want to use this model data to recreate my project on the web using Three.js."


First problem was getting the right transformation form nested parts. Thanks to this post: this is solved. But not quite.

The resultant assembly is not showing the right location of the parts since these parts have a "Rigid Joint" and therefore, their location is not the same as the transformation matrix. (see picture below)

Top view: Left-> Fusion; Right-> ViewerTop view: Left-> Fusion; Right-> Viewer


The positioning of the parts directly relates to their respective origins, but I can't get the information remaining, which is the location of the rigid joint of each leg assembly to the top table so I can calculate the resultant final location.


legs offsetlegs offset


So I guess my question is if there is a way of getting the Occurrence/BRepBody position or transformation matrix based on the overall origin and not its own origin?

Labels (1)
Message 2 of 4
in reply to: xenia.pie

Hi @xenia.pie .


At the time, I did not have enough knowledge about proxies.


Now I understand that it is not possible to get the matrix 3D from the component.


Can't I get the correct matrix this way?

def getRootMatrix(
        occ: adsk.fusion.Occurrence) -> adsk.core.Matrix3D:

    des: adsk.fusion.Design = occ.component.parentDesign
    root: adsk.fusion.Component = des.rootComponent

    occ_names = occ.fullPathName.split('+')
    occs = [root.allOccurrences.itemByName(name)
            for name in occ_names]

    mat: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
    mat3ds: list = [occ.transform for occ in occs]
    mat3ds.reverse()  # important!!

    for mat3d in mat3ds:

    return mat
Message 3 of 4
in reply to: xenia.pie

It doesn't matter if an occurrence is positioned with a joint or moved to a location by the user.  It's current location is independent of how it got there.  There does seem to be a problem with the transform being returned by an occurrence.  In my testing, it seems it's always returning a transform that is relative to the assembly it's directly in.  If the occurrence is a proxy that defines the full path to the occurrence, the transform should be with respect to that full path.


Here's a workaround that builds the full transform using the proxy path.  You'll get occurrence proxies if the user selects an occurrence, if you use the allOccurrences property on the root component, or if you traverse the assembly structure by starting with the occurrences in the root component and use the childOccurrences property of the Occurrence object to step down.  You can pass in an occurrence obtained in any of these ways into this function and it should return the transform relative to root.


# Give an occurrence, this will combine all the transforms in it's
# assembly structure to return a transform for the occurrence that
# is with respect to the root assembly.
def getFullTransform(occ: adsk.fusion.Occurrence) -> adsk.core.Matrix3D:
    trans = occ.transform

    while occ.assemblyContext is not None:
        contextOcc = occ.assemblyContext
        occ = occ.assemblyContext

    return trans


Brian Ekins
Inventor and Fusion 360 API Expert
Message 4 of 4
in reply to: BrianEkins

Hi there @BrianEkins,


I just implemented what you suggest and what I get is not quite the transform matrix relative to root. I'm passing the occurrences one by one to this method "getFullTransform", but the resultant matrix is not right.

(Image attached of the resultant full assembly.)



Please see 3D model attached.

Thank you,



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