Convert Brep face to mesh C#

Hi,

What would be the method to convert brep faces to meshes?
(I know that I could do Mesh.CreateFromBrep(brep, MeshingParameters.Default)[0]; but I need to convert individual trimmed brep faces )

When I try to convert each brep face I got untrimmed brep mesh conversion:

  private void RunScript(Brep B, ref object A)
  {

    List<Mesh> meshes = new List<Mesh>();

    foreach(BrepFace f in B.Faces){
      Mesh mesh = Mesh.CreateFromBrep(f.ToBrep(), MeshingParameters.Default)[0];
      meshes.Add(mesh);
    }
    
    A = meshes;

  }

It seems to work with that :

List meshes = new List();

foreach(BrepFace f in brep.Faces){

  Brep newFace = f.DuplicateFace(false);
  Mesh mesh = Mesh.CreateFromBrep(newFace, MeshingParameters.Default)[0];
  meshes.Add(mesh);
}

A = meshes;

cf.

brep face to mesh per face.gh (80.6 KB)

Thank you:slight_smile:

Maybe you have an idea how to match meshed breps
so that edge vertices would be the same for adjacent brep faces?

connection

I don’t find this option in meshing parameter.
I understood that Mesh2 has this possibility to have mesh with same vertex on seam.
I don’t know if it is in Rhinocommon.

Hi Laurent, Mesh2 is still a WIP plug-in. It has no API.