algorithmic modeling for Rhino
Hello everybody.
How do I convert a brep to mesh using Rhinocommon methods?
public Rhino.Geometry.Mesh CreateMesh() {
Rhino.Geometry.Mesh myMesh = new Rhino.Geometry.Mesh();
Rhino.Geometry.Point3d pt0 = new Rhino.Geometry.Point3d(0, 0, 0);
Rhino.Geometry.Point3d pt1 = new Rhino.Geometry.Point3d(10, 10, 10);
Rhino.Geometry.BoundingBox box = new Rhino.Geometry.BoundingBox(pt0, pt1);
Rhino.Geometry.Brep brep = box.ToBrep();
myMesh = Rhino.Geometry.Mesh.CreateFromBrep(brep); // Line 7
return myMesh;
}
Line 7 generates an error: Error 1 Cannot implicitly convert type 'Rhino.Geometry.Mesh[]' to 'Rhino.Geometry.Mesh'
Feel like I have to convert the type myself but have no idea how to do so.
Thank you
Tags:
that means that this statement
Rhino.Geometry.Mesh.CreateFromBrep(brep)
will return a list of meshes, rather than a single mesh. You can probably find a function in RhinoCommon that welds multiple meshes into one, but basically you just need to deal with the list.
Mesh.Append()
Thanks, guys
Apparently, if I only have one mesh being drawn, it is assigned an index of [0]. So all I had to do was to specify that index in the CreateFromBrep method, like this:
myMesh = Rhino.Geometry.Mesh.CreateFromBrep(brep)[0];
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by