Visualizing edge or face from GUI based on memory adress

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
FreeMake
Posts: 33
Joined: Tue Mar 19, 2019 12:10 pm

Visualizing edge or face from GUI based on memory adress

Post by FreeMake »

As I am scripting I often use print statements to debug. This tells me for example that the following edge objects are causing an issue:

Code: Select all

[<Edge object at 000001B20F821FA0>, <Edge object at 000001B20F822820>, <Edge object at 000001B20F8224A0>, <Edge object at 000001B20F821B60>, <Edge object at 000001B20F821E60>]
However, visually that does not tell me a lot. Is there someway to visualize this? Or is there an inspect tool or something that if you click on an edge or a face that it gives the memory adress?
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Visualizing edge or face from GUI based on memory adress

Post by Joel_graff »

The easiest approach is to print out the edge vertices:

Code: Select all

for edge in edge_list:
  print(edge.Vertexes[0].Point, edge.Vertexes[1].Point)

You could try selecting them in the GUI, but that would require knowing the edge's index in it's parent shape, which gets a bit more complicated:

Code: Select all

for index in range(0, len(my_obj.Shape.Edges)):
    cur_edge = my_obj.Shape.Edges[index]
    
    for edge in edge_list:
        if edge.Vertexes[0].Point == curEdge[0].Point and edge.Vertexes[1].Point == curEdge[1].Point:
            Gui.Selection.addSelection(my_obj, 'Edge' + str(index))

Note that 'Gui' is a common alias for 'FreeCADGui' (i.e., 'import FreeCADGui as GUI').

I don't think you can rely on comparing memory locations, though I could be wrong about that...
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
naxq0
Posts: 51
Joined: Wed Apr 25, 2018 7:45 am

Re: Visualizing edge or face from GUI based on memory adress

Post by naxq0 »

If you run it as macro within the FreeCAD GUI or directly in the python interpreter, you can just plot them:

Code: Select all

Part.show(edge_that_you_are_interested_in, "some_nice_name")
FreeMake
Posts: 33
Joined: Tue Mar 19, 2019 12:10 pm

Re: Visualizing edge or face from GUI based on memory adress

Post by FreeMake »

Thanks naxq, that was exactly what I was looking for!
Post Reply