Issues querying coordinates from construction points

en9y37
Advocate

Issues querying coordinates from construction points

en9y37
Advocate
Advocate

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?

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

en9y37
Advocate
Advocate

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

0 Likes

kandennti
Mentor
Mentor
Accepted solution

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()))
1 Like

en9y37
Advocate
Advocate

Thanks a lot @kandennti !!!!

That works great. You saved me... again

0 Likes

BenHarper-3Dtek
Contributor
Contributor

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

It looks very handy!

0 Likes