What's new

Is there a way to get the edge that 2 faces share?

albie0803

Alibre Super User
Just what it says. I have a cylinder and 1 end and I want to find out the name of the edge that they share.
 
Without having the input it's not entirely clear but here is my interpretation:

Python:
def GetSharedEdge(FaceA, FaceB):
    EdgesA = FaceA.GetEdges()
    EdgesB = FaceB.GetEdges()

    for EdgeA in EdgesA:
        for EdgeB in EdgesB:

            VerticesA = EdgeA.GetVertices()
            VerticesB = EdgeB.GetVertices()

            VerticesASet = {(v.X, v.Y, v.Z) for v in VerticesA}
            VerticesBSet = {(v.X, v.Y, v.Z) for v in VerticesB}

            if VerticesASet == VerticesBSet:
                return EdgeA

    return None
P = CurrentPart()

Face1 = P.GetFace("Face<1>")
Face2 = P.GetFace("Face<2>")

SharedEdge = GetSharedEdge(Face1, Face2)

if SharedEdge:
    print("Shared Edge Found:", SharedEdge.Name)
else:
    print("No shared edge between the faces.")

1740541629820.png

 
Last edited:
Thanks Stephen I will have a look at it.

Next question,
I am trying to combine 2 scripts and there are parts that are identical that need to be called at different times. Basically, how do I write a gosub that just does a list of things but doesn't need to return a value?

Like this?
Def BuildTooth()
do things here
Return None


BuildTooth()
 
That is correct, but return is optional. AI is great with these kinds of general IronPython/Python programming questions.

Here is a script with a function without return:

and another with and without:

 
Back
Top