Grasshopper

algorithmic modeling for Rhino

I am trying to acquire a list of all edges in a mesh,using python, but since Rhino does not have this "embedded", I came around this code, which works that out in a bit funny way.

Does anyone has better ideas?

def MeshEdges(mesh):
  faces = rs.MeshFaces(mesh, True)
  edges = []
  i = 0
  while( i<len(faces) ):
    edges.append([faces[i], faces[i+1]])
    edges.append([faces[i+1], faces[i+2]])
    if (faces[i+2] != faces[i+3]):
        edges.append([faces[i+2], faces[i+3]])
      edges.append([faces[i+3], faces[i]])
      i += 4
# we should remove duplicate (from shared) edges in the future!
return edges

Views: 784

Attachments:

Replies to This Discussion

Attached an example of two ways of doing it (both use RhinoCommon mesh methods directly). Neither yields duplicates. Hope that helps.

Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service