A mesh is a collection of triangular boundaries which collectively forms a 3D shape. Meshes are typically encountered inside Revit element geometry if those elements were created from certain import operations and also are used in some native Revit elements such as TopographySurface. You can also obtain Meshes as the result of calls to Face.Triangulate() for any given Revit face.
A mesh representing a torus
The following code sample illustrates how to get the geometry of a Revit face as a Mesh:
Code region: Extracting the geometry of a mesh |
private void GetTrianglesFromFace(Face face) { // Get mesh Mesh mesh = face.Triangulate(); for (int i = 0; i < mesh.NumTriangles; i++) { MeshTriangle triangle = mesh.get_Triangle(i); XYZ vertex1 = triangle.get_Vertex(0); XYZ vertex2 = triangle.get_Vertex(1); XYZ vertex3 = triangle.get_Vertex(2); } } |