How to get objectInfo from given world coordinates

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
MrRossi
Posts: 107
Joined: Thu Dec 01, 2016 7:30 am

How to get objectInfo from given world coordinates

Post by MrRossi »

Hello Community

Would need some help again:
I know it`s possible to get object info froma clicked point in the active view, with Pivy obserers for example.
(getObjectInfo())
I`m wondering whether it`s possible to get this also from a given 2D world coordinates point?
E.g. we have point x= 200, y=0. Is there an object on that point.
Or is there a chnace to convert the world coordinates to the pixel coordinates?
So, the opposite of getPoint(pos).

Thanks for help.

Regards

Chris
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to get objectInfo from given world coordinates

Post by openBrain »

Can't check now, but AFAIR there is a function

Code: Select all

getObjectsInfo(x, y)
MrRossi
Posts: 107
Joined: Thu Dec 01, 2016 7:30 am

Re: How to get objectInfo from given world coordinates

Post by MrRossi »

Code: Select all

getObjectInfo(x, y)
can be used with a Pivy Mouse Observer if using the screen coordinates, but not the drawing world
coordinates (from placement).
If I wanna use this function I have to convert, but I don`t know whether this is possible somehow.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to get objectInfo from given world coordinates

Post by openBrain »

This isn't exactly same function (notice the 's' at the end of 'objects'). But indeed not very reliable information as I'm with a mobile now and using my memory.
:)
MrRossi
Posts: 107
Joined: Thu Dec 01, 2016 7:30 am

Re: How to get objectInfo from given world coordinates

Post by MrRossi »

What I found out by myself is, the difference between the both (one with "s" the other without) is just
the number of objects under the cursor.
If using

Code: Select all

getObjectInfo
returns only information of 1 object.

Code: Select all

getObjectsInfo
returns a list with information of all objects.

Maybe I`m wrong ? :o
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to get objectInfo from given world coordinates

Post by openBrain »

Not sure to understand. Only the viewport is 2D. The scene is 3D everywhere actually. So as well is a Placement. Would you provide a simple example to explain?
MrRossi
Posts: 107
Joined: Thu Dec 01, 2016 7:30 am

Re: How to get objectInfo from given world coordinates

Post by MrRossi »

I have a solution. With this

Code: Select all

FreeCADGui.activeDocument().activeView().getCursorPos()
I get the cursor position and not the coordinates and I can work with

Code: Select all

getObjectInfo
.

Thanks for help.

Greetings
Chris
Post Reply