get the face of a edge

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Vincent B
Veteran
Posts: 4733
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

get the face of a edge

Post by Vincent B »

If I select an edge or a vertex, how to get the face from it?
thx a lot.
Last edited by Vincent B on Sat Jun 12, 2021 8:59 pm, edited 1 time in total.
User avatar
Chris_G
Veteran
Posts: 2598
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: get the face of a edge

Post by Chris_G »

I assume you have access to the main shape.
Select the edge of an object and try :

Code: Select all

sel = Gui.Selection.getSelectionEx()[0]
edge = sel.SubObjects[0]
shape = sel.Object.Shape
faces = shape.ancestorsOfType(edge, Part.Face)
print(faces)
User avatar
Vincent B
Veteran
Posts: 4733
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: get the face of a edge

Post by Vincent B »

one time again, thx a lot!
Post Reply