Fixing Invalid Mesh in Grasshopper

Hello,
I am trying to write a C# script that will automate mesh fixing at the end of my grasshopper definition, before exporting. 99% of the time the mesh has 1 or 2 degenerate faces that can be easily fixed using the Rhino CullDegenerateFaces command and then there’s no more problem. However, I am trying to create a small C# component that will automate this for me. Any ideas how this could be done?

I am trying to use
private void RunScript(Mesh M, ref object R)
{
if (M != null) {

  M.Faces.CullDegenerateFaces();
  M.RebuildNormals();

  R = M;
}

}

but the mesh coming out still has degenerate faces. Strangely, they are easily removed with the standard Rhino command. Is there a difference? Maybe Im missing a step somewhere. Any help would be greatly appreciated.
Thanks in advance!

Hello
you are not alone, since V6 mesh must be better!!

I do that

  foreach(Mesh stlMesh in stlMeshes)
      {
        stlMesh.Vertices.CombineIdentical(true, true);
        stlMesh.Faces.CullDegenerateFaces();
        stlMesh.UnifyNormals();
        stlMesh.RebuildNormals();
        stlMesh.Compact();
      }

from these discussions

1 Like

Thank you! Will try these.

If you have a particular mesh that can’t be cured in Grasshopper and be cured in Rhinoceros, it will be interesting you post it.

Yeah these seem to work pretty well for now. Thank you for the help!

Cool if it works. Seeing the commands I am not sure if unify normals is at the good place or if it is necessary. It is just cosmetics.
If you find mesh that are not heal or better script don’t hesitate to post.

Hello,

I discovered that the Pufferfish module has a component called “Rebuild Mesh” with these options and thought I’d share.

1 Like