Hi all , Since I found no method same as ( Grasshopper: Construct mesh ) in Rhinocommon , What is the proper way to make mesh from faces and vertices ?
Hi @sagkoyeou,
Something like this should do:
var mesh = new Mesh();
// Add vertices
mesh.Vertices.Add(new Point3d(0.5, 0.5, 0.5));
mesh.Vertices.Add(new Point3d(0.5, 0.5, -0.5));
mesh.Vertices.Add(new Point3d(0.5, -0.5, 0.5));
mesh.Vertices.Add(new Point3d(0.5, -0.5, -0.5));
mesh.Vertices.Add(new Point3d(-0.5, 0.5, 0.5));
mesh.Vertices.Add(new Point3d(-0.5, 0.5, -0.5));
mesh.Vertices.Add(new Point3d(-0.5, -0.5, 0.5));
mesh.Vertices.Add(new Point3d(-0.5, -0.5, -0.5));
// Add faces
mesh.Faces.AddFace(0, 1, 5, 4);
mesh.Faces.AddFace(0, 4, 6, 2);
mesh.Faces.AddFace(0, 2, 3, 1);
mesh.Faces.AddFace(7, 3, 2, 6);
mesh.Faces.AddFace(7, 6, 4, 5);
mesh.Faces.AddFace(7, 5, 1, 3);
// Compute normals
mesh.FaceNormals.ComputeFaceNormals();
mesh.Normals.ComputeNormals();
// Cleanup
mesh.Compact();
// TODO...
– Dale
2 Likes
Nice Dale! Having some fun with your script
The File : proceduralMesh.gh (15.9 KB)
1 Like