getObjectInfo question

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

getObjectInfo question

Post by malinand »

Function Gui.ActiveDocument.ActiveView.getObjectInfo((x,y)) used in Draft module in snap function implementation.
It returns refernces to one object only. If there is more then one under the cursor function returns refernce to first object in the list, which is covered by last object on the screen.
Is it possible get information about all objects? Or at least reverse of search sequence.
Is it possible to set up this function to return only Edges? I can get this information from "Component" property, but it is very often return Face as component, so not very useful.
Is it possible to set aperture for this function?

Thank you
Andrey
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: getObjectInfo question

Post by wmayer »

Is it possible get information about all objects?
Basically yes. Maybe a parameter can be added to look for all objects then.
Is it possible to set up this function to return only Edges? I can get this information from "Component" property, but it is very often return Face as component, so not very useful.
I cannot confirm this. For me it works. For instance if you create a box and put the cursor over an edge then

Code: Select all

v=Gui.ActiveDocument.ActiveView
p=v.getCursorPos()
v.getObjectInfo(p)
gives the following output:
{'Document': 'Unnamed', 'Object': 'Box', 'Component': 'Edge12', 'y': 10.0, 'x': 2.4556193351745605, 'z': 10.0}

Werner
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: getObjectInfo question

Post by jriegel »

Maybe we can handle this with the Selection.
A methode returns the actual preselected element as an SelectionObject.
This object has all the information needed. Object, Document, Subelement and x,y,z position.
I think thats the info you need?!

Jürgen
Stop whining - start coding!
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

Re: getObjectInfo question

Post by malinand »

Hi Werner
wmayer wrote:
Is it possible to set up this function to return only Edges? I can get this information from "Component" property, but it is very often return Face as component, so not very useful.
I cannot confirm this. For me it works. For instance if you create a box and put the cursor over an edge then

Code: Select all

v=Gui.ActiveDocument.ActiveView
p=v.getCursorPos()
v.getObjectInfo(p)
gives the following output:
{'Document': 'Unnamed', 'Object': 'Box', 'Component': 'Edge12', 'y': 10.0, 'x': 2.4556193351745605, 'z': 10.0}
I agree. I probably didn't explain the problem:
If you draw rectangle in Draft module and start to draw the line. You will see that snap catch the edge and hold it when cursor close to the edge, even not exactly on top of it.
If you will upgrade rectangle to the Face, you will see the same behavior when cursor is outside the rectangle. But it doesn't hold focus if cursor moved inside.
I would like to make snap work only with the edges. And if line is on top of the face I would like to be able to work with it as well.
Another problem with the snap as it implemented in Draft module - for object snap, when ctrl is presssed, it looks trough all edges of the preselected component. It works well for simple lines. But for long polylines or complex faces it take a while to search for intersection. I think the easest way to solve the problem is to do the search only for one edge. But this requires snap to keep focus on it.

Thanks
Andrey
malinand
Posts: 31
Joined: Sun Aug 02, 2009 2:10 am

Re: getObjectInfo question

Post by malinand »

jriegel wrote:Maybe we can handle this with the Selection.
A methode returns the actual preselected element as an SelectionObject.
This object has all the information needed. Object, Document, Subelement and x,y,z position.
I think thats the info you need?!

Jürgen
Hi Jürgen,
It looks like SelectionObject gives the same information as getObjectInfo and has the same behavior. I will have the same problems with SelectionObject as I have now, isn't it?

Andrey
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: getObjectInfo question

Post by jriegel »

Not if we implement a Selection Filter to force (pre)selection only on chosen (sub)objects. ;)
Stop whining - start coding!
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: getObjectInfo question

Post by yorik »

malinand wrote:If you will upgrade rectangle to the Face, you will see the same behavior when cursor is outside the rectangle. But it doesn't hold focus if cursor moved inside. I would like to make snap work only with the edges. And if line is on top of the face I would like to be able to work with it as well.
I think the current behaviour is fine, If you have only a standalone edge, the preselect mechanism activates as soon as you come close to it with the mouse cursor. If you are already on a face, the face is preselected until you are really on top of the edge... It makes sense actually, if there is a face under your cursor you might want to snap to it, very close to the edge... I wonder how that preselect "distance" is set? is it a variable somewhere that could become a preference?

One thing I could do in the draft module, is desconsider faces for snapping...But I found that great, because it allows you to draw 2D stuff directly on the faces of 3D objects, like in sketchup :) Maybe a toggle that would switch faces snapping on/off? But it would require one more user operation when you draw... What do you think? Actually until now I haven't found this a big problem...

Ah, you might all get pleased to know that I now use FreeCAD regularly in my work... Still for doing simple things like opening and converting files between dxf and svg, or transforming open wires into faces, things like that, but it's a beginning. At least it is now really part of my usual toolchain and the dxf import -> draft 2D work -> svg export sequence works pretty well.

Now I must enable to import/export dims to dxf & svg and we are almost set up for outputting professional-looking dxf drawings too. Then I can move on to really interesting stuff!
Post Reply