Object at Screen Position

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Object at Screen Position

Post by wandererfan »

Is there existing functionality that, given a screen position (x, y) in a 3D window will return the object + subObject at that location? Preferably the "top most" object.

This is effectively emulating a mouse click, I guess, without invoking the action associated with the mouse click.

Code: Select all

myObject, mySubObject = mainWindow.objectAt(x, y
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Object at Screen Position

Post by Chris_G »

Code: Select all

pos = Gui.ActiveDocument.ActiveView.getCursorPos()
Gui.ActiveDocument.ActiveView.getObjectInfo(pos)
returns something like :

Code: Select all

{'x': -0.8382894992, 'y': 0.164370581, 'z': 0.0, 'Document': 'Unnamed', 'Object': 'Extrude', 'Component': 'Face1'}
User avatar
wandererfan
Veteran
Posts: 6326
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Object at Screen Position

Post by wandererfan »

Chris_G wrote: Sun Oct 13, 2019 4:24 pm

Code: Select all

pos = Gui.ActiveDocument.ActiveView.getCursorPos()
Gui.ActiveDocument.ActiveView.getObjectInfo(pos)
returns something like :

Code: Select all

{'x': -0.8382894992, 'y': 0.164370581, 'z': 0.0, 'Document': 'Unnamed', 'Object': 'Extrude', 'Component': 'Face1'}
Perfect! Merci monsieur!
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Object at Screen Position

Post by Chris_G »

wandererfan wrote: Sun Oct 13, 2019 5:00 pm Merci monsieur!
:D
mea08kw
Posts: 82
Joined: Sun Oct 09, 2022 6:22 am

Re: Object at Screen Position

Post by mea08kw »

What if convert object position (x, y, z) into screen position (only x, y)?
User avatar
Roy_043
Veteran
Posts: 8578
Joined: Thu Dec 27, 2018 12:28 pm

Re: Object at Screen Position

Post by Roy_043 »

mea08kw
Posts: 82
Joined: Sun Oct 09, 2022 6:22 am

Re: Object at Screen Position

Post by mea08kw »

Roy_043 wrote: Fri Feb 17, 2023 11:37 am See: viewtopic.php?p=661300#p661300
Further discussion will be followed by this link.
Post Reply