Get unique mesh edges in GHPython with rhinocommon?

Hi,

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])
        else:
            edge = rg.LineCurve(vertices[i], vertices[0])
        edges.append(edge)

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:

https://developer.rhino3d.com/5/api/RhinoCommonWin/html/M_Rhino_Geometry_Collections_MeshTopologyEdgeList_EdgeLine.htm

Edit: Like so:

2 Likes

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