Any examples of how to create a breps from raw meshes in RhinoCommon?

Suppose I have a vertex list:

((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1))

and a face list that indexes into the vertex list (this one for the surface of a cube with each cube face divided into triangular facets):

((1, 6, 5), (6, 7, 5), (8, 3, 4), (3, 1, 4), (1, 8, 4), (1, 3, 2), (3, 7, 2), (7, 6, 2), (6, 1, 2), (7, 3, 8), (8, 1, 5), (7, 8, 5))

Are there any examples that would hint at how to turn this into a Rhino Brep using RhinoCommon?

Chris

I found the answer in the examples for ObjectTable.AddMesh.

Chris

Here is a simple example:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  double xdim = 15.0;
  double ydim = 10.0;
  double zdim = 5.0;

  Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();
  mesh.Vertices.Add(0.0, 0.0, 0.0);
  mesh.Vertices.Add(xdim, 0.0, 0.0);
  mesh.Vertices.Add(xdim, ydim, 0.0);
  mesh.Vertices.Add(0.0, ydim, 0.0);
  mesh.Vertices.Add(0.0, 0.0, zdim);
  mesh.Vertices.Add(xdim, 0.0, zdim);
  mesh.Vertices.Add(xdim, ydim, zdim);
  mesh.Vertices.Add(0.0, ydim, zdim);

  mesh.Faces.AddFace(0, 1, 2, 3);
  mesh.Faces.AddFace(0, 1, 5, 4);
  mesh.Faces.AddFace(1, 2, 6, 5);
  mesh.Faces.AddFace(2, 3, 7, 6);
  mesh.Faces.AddFace(3, 0, 4, 7);
  mesh.Faces.AddFace(4, 5, 6, 7);

  mesh.Normals.ComputeNormals();
  mesh.Compact();

  Rhino.DocObjects.ObjectAttributes attribs = doc.CreateDefaultAttributes();
  attribs.Name = "Sample Mesh";

  doc.Objects.AddMesh(mesh, attribs);
  doc.Views.Redraw();

  return Result.Success;
}

What I don’t understand is why you want to create a Brep from the mesh. Can you explain?

At the time I thought that to get the geometry into Rhino, I had to turn it into a Brep. I didn’t know that Mesh is an alternative.

But I’m still wondering: if I have, for example, an arbitrary parametric surface and don’t want to lose resolution or efficiency by discretizing it, what’s the best way to get it into Rhino?

Not knowing full details, I’d tell you to create a NurbsSurface.