Get unique mesh edges in GHPython with rhinocommon?


Is there a way to get the unique mesh edges in rhinocommon, without duplicate edges.
I currently construct the mesh edges for each face, from the face vertices.

result = list(my_mesh.Faces.GetFaceVertices(my_index))
edges = []
if result[0]: # success
    vertices = list(result[1:])
    for i in range(len(vertices)):
        if i < len(vertices) - 1:
            edge = rg.LineCurve(vertices[i], vertices[i+1])
            edge = rg.LineCurve(vertices[i], vertices[0])

However, this is problematic, since it produces a duplicate edge/line for each face edge that has a neighbour. I would prefer to construct each shared edge only once.

Any suggestions?

It’s probably simpler going with this method:

Edit: Like so:


Amazing suggestion, @AndersDeleuran! :slight_smile:

Do you know by any chance, if there is a way to find out, which faces are adjacent to a certain edge/line from the topology edges?

Hi @diff-arch,

MeshTopologyEdgeList.GetEdgesForFace should get you there.

MeshTopologyEdgeList.GetConnectedFaces is another useful function.

– Dale

1 Like