Hi…,
I want to get all mesh quads with their vertices and their quad normal in Python.
I don’t see, which methods to use:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#mesh
Can someone help?
Thanks
Michael
www.flexiCAD.com
Hi…,
I want to get all mesh quads with their vertices and their quad normal in Python.
I don’t see, which methods to use:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#mesh
Can someone help?
Thanks
Michael
www.flexiCAD.com
Hi…,
sorry, I’ve found everything myself, it looks like this:
obj = rs.GetObject("Select mesh", rs.filter.mesh)
faceVerts = rs.MeshFaceVertices( obj )
normals = rs.MeshFaceNormals( obj )
verts = rs.MeshFaces( obj, True)
if faceVerts and normals and verts:
for count, face in enumerate( faceVerts ):
firstVertex = count * 4
if face[2] == face[3]:
print " tri v0: ", verts[ firstVertex ], "v1: ", verts[ firstVertex + 1 ], "v2: ", verts[ firstVertex + 2 ], " normal: ", normals[ count ]
else:
print "quad v0: ", verts[ firstVertex ], "v1: ", verts[ firstVertex + 1 ], "v2: ", verts[ firstVertex + 2 ], "v3: ", verts[ firstVertex + 3 ], " normal: ", normals[ count ]
Thanks
Michael
import rhinoscriptsyntax as rs
import ghpythonlib.treehelpers as th
vertices = rs.MeshVertices(mesh)
face_vertices = rs.MeshFaceVertices(mesh)
v = []
for i in range(rs.MeshFaceCount(mesh)):
temp = []
for j in face_vertices[i]:
temp.append(vertices[j])
v.append(temp)
v = th.list_to_tree(v)
n = rs.MeshFaceNormals(mesh)
c = rs.MeshFaceCenters(mesh)
deMesh.gh (19.6 KB)