Looking for way to MergeAllCoplanarFaces from C# for a Mesh

I’m looking for a way to merge all coplanar mesh faces in Rhino common from C#. This functionality is available in Rhino7 UI in the _MergeAllCoplanarFaces command.

I see Brep.MergeAllCoplanarFaces(), but do not see the equivalent for a Mesh.

Thanks!

Hi. There is an SDK function that takes geometry as input including meshes that should hel. Look for RhinoMergeCoplanarFaces

Hi, and thanks for the feedback!

I’m using the .NET plugin SDK NuGet Gallery | RhinoCommon 7.6.21127.19001. I don’t see it there.

It does not look like it is ported to RhinoCommon.
I added a request to do that here…

1 Like

Hi @rajaa Was this command finally added to RhinoCommon and is there another way to do it with Python vb or macro?

RH-64373 is fixed in Rhino 7 Service Release 9

Thanks for add this To sdk
this component is MergeAllCoplanarFaces for Brep Mesh SubD

 private void RunScript(GeometryBase geometry, bool MeshToSubd, ref object Geometry, ref object Result)
  {
    if (null != geometry)
    { string R = geometry.GetType().ToString();
      if(R == "Rhino.Geometry.Brep")
      { var x = Brep.TryConvertBrep(geometry);


        Geometry = x.MergeCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance);
        Result = Geometry;
        Geometry = x;
      }
      else if(R == "Rhino.Geometry.Mesh" && MeshToSubd == false)

      { var x = geometry  as Mesh;
        Geometry = x.MergeAllCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance, RhinoDocument.ModelAngleToleranceRadians);
        Result = Geometry;
        Geometry = x;}
      else if(R == "Rhino.Geometry.Mesh" && MeshToSubd)

      { var x = geometry  as Mesh;
        var y = SubD.CreateFromMesh(x);
        Geometry = y.MergeAllCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance, RhinoDocument.ModelAngleToleranceRadians);
        Result = Geometry;
        Geometry = y;}
      else if((R == "Rhino.Geometry.SubD"))
      { var x = geometry  as SubD;
        Geometry = x.MergeAllCoplanarFaces(RhinoDocument.ModelAbsoluteTolerance, RhinoDocument.ModelAngleToleranceRadians);
        Result = Geometry;
        Geometry = x;}
      else
      {Geometry = geometry;}}
  }

MergeAllCoplanarFaces+A.gh (27.5 KB)

1 Like