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
getObjectInfo question
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: getObjectInfo question
Basically yes. Maybe a parameter can be added to look for all objects then.Is it possible get information about all objects?
I cannot confirm this. For me it works. For instance if you create a box and put the cursor over an edge thenIs 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.
Code: Select all
v=Gui.ActiveDocument.ActiveView
p=v.getCursorPos()
v.getObjectInfo(p)
{'Document': 'Unnamed', 'Object': 'Box', 'Component': 'Edge12', 'y': 10.0, 'x': 2.4556193351745605, 'z': 10.0}
Werner
Re: getObjectInfo question
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
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!
Re: getObjectInfo question
Hi Werner
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
I agree. I probably didn't explain the problem:wmayer wrote:I cannot confirm this. For me it works. For instance if you create a box and put the cursor over an edge thenIs 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.gives the following output:Code: Select all
v=Gui.ActiveDocument.ActiveView p=v.getCursorPos() v.getObjectInfo(p)
{'Document': 'Unnamed', 'Object': 'Box', 'Component': 'Edge12', 'y': 10.0, 'x': 2.4556193351745605, 'z': 10.0}
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
Re: getObjectInfo question
Hi Jürgen,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
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
Re: getObjectInfo question
Not if we implement a Selection Filter to force (pre)selection only on chosen (sub)objects.
Stop whining - start coding!
Re: getObjectInfo question
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?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.
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!