Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to find origin point relative to design of a moved component

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
459 Views, 1 Reply

How to find origin point relative to design of a moved component

If a user moves a component (not just the bodies) the origin of the component moves with it. However from the Python Scripts if you ask for the geometry of the component's originConstructionPoint, it still reporst (0,0,0) and if you try to get the vector from the rootComponent's origin to the components origin, it is just <0,0,0> which is wrong?

 

How do you get the "world Geometry" of a component's origin after it has been moved?

1 REPLY 1
Message 2 of 2
liujac
in reply to: Anonymous

You need to create an object with assembly context. Please try the code below.

 

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

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent
        occs = root.occurrences
        occ = occs[0]
        comp = occ.component
        origin = comp.originConstructionPoint
        originProxy = origin.createForAssemblyContext(occ)
        point = originProxy.geometry
        ui.messageBox('X:{}, Y:{}, Z:{}'.format(point.x, point.y, point.z));

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

 

Jack

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