Help for Mesh. MergeAllCoplanarFaces API(IN GRASSHOPPER)

HI i need merge Mesh. MergeAllCoplanarFaces API(IN GRASSHOPPER) for Mesh(or SubD)
In Python C # or Rhinoscriptsyntax,…???
Is there a way for MergeCoplanarFaces Work in grasshopper as well as this performance in Rhino for( Mesh Brep and Subd)?
Of course I wrote MergeCoplanarFaces command according to the relevant API for BREPOnly!!, but does not act for Mesh and SUBD


MergeCoplanarFaces(mesh).gh (13.5 KB)

  private void RunScript(Brep Brep, ref object brep, ref object Result)
  {
    if (null != Brep)
    { brep = Brep.MergeCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance);
      Result = brep;
      brep = Brep;}

@dale
@Mahdiyar

1 Like

Looks like this api hasn’t been added yet
is there another way to do it with Python vb or macro?( in grasshopper)

Perhaps MeshNgonList.AddPlanarNgons is the magic?

– Dale

2 Likes
private void RunScript(Mesh mesh, ref object A)
{
  mesh.Ngons.AddPlanarNgons(RhinoDocument.ModelAbsoluteTolerance);
  A = mesh;
}

MergeAllCoplanarFaces.gh (4.6 KB)

1 Like

thanks @Mahdiyar please fix this one

 private void RunScript(Mesh mesh, bool trimmedTriangles, bool MergFace, ref object brep)
  {
    brep = Brep.CreateFromMesh(mesh, trimmedTriangles);
    if (MergFace == true){
      brep.MergeCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance);     
      }

AddPlanarNgons (merg coplanerMesh).gh (27.2 KB)

private void RunScript(Mesh mesh, bool trimmedTriangles, bool mergeFaces, ref object A)
{
  var brep = Brep.CreateFromMesh(mesh, trimmedTriangles);
  if (mergeFaces)
    brep.MergeCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance);
  A = brep;
}

Ehsan.gh (10.7 KB)

1 Like