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: 

Issues querying coordinates from construction points

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
en9y37
264 Views, 5 Replies

Issues querying coordinates from construction points

Hi there.

 

I have defined one construction point within each component in my design by the three planes method.

en9y37_0-1666083966978.png

 

 

If I query the coordinates of this construction points using the API Object Explorer, I get the right coordinates if I select the construction points directly from the browser or from the Time Line:

 

en9y37_1-1666084233741.png

 

The issues come when I query the coordinates via this object:

 

component.constructionPoints.itemByName('_O_').geometry

 

The coordinates I get in this case are these:

en9y37_2-1666084608397.png

 

I have also tried to get these coordinates through the timeline, and the output is still wrong:

 

en9y37_3-1666084791709.png

 

Any idea about what object should I use to get the right coordinates?

5 REPLIES 5
Message 2 of 6
en9y37
in reply to: en9y37

In order to give more information, I've just noticed that the coordinates issue only happens in those components in which their own coordinates systems don't match the root component origins.

 

en9y37_0-1666091123802.png

en9y37_1-1666091170921.png

In this case this happens because one component was created by simetry from another.... I'll keep on researching

Message 3 of 6
kandennti
in reply to: en9y37

Hi @en9y37 .

 

Try this.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

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

        msgLst = []

        for occ in root.allOccurrences:
            comp: adsk.fusion.Component = occ.component
            for constPoint in comp.constructionPoints:
                point: adsk.core.Point3D = constPoint.geometry
                point.transformBy(occ.transform2)

                msgLst.extend(
                    [
                        f'<< {occ.name} : {constPoint.name} >>',
                        f'ConstructionPoint.geometry : {constPoint.geometry.asArray()}',
                        f'transformBy(occurrence.transform2) : {point.asArray()}\n',
                    ]
                )

        ui.messageBox('\n'.join(msgLst))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Message 4 of 6
en9y37
in reply to: kandennti

Thanks a lot @kandennti !!!!

That works great. You saved me... again

Message 5 of 6
BenHarper-3Dtek
in reply to: en9y37

May I ask, where do you find this "API Object Explorer" !?!

It looks very handy!

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