A closed mesh how can flip it to normal?

Good day, I have a solid mesh when I import it from a *.stl file. It’s solid but the direction is reversed. I can use _Flip or _FillHoles Command to make it right easily. But I can’t get the right result in my C# project. mesh.Flip(True,True,True) or mesh.Fillholes() don’t work. Does anyone meet this question before?

0306Files.stl (3.9 KB)

Rhino.Geometry.Mesh.UnifyNormals() is probably what you are looking for.

Thank you, diff-arch. but it still didn’t work out. Even I used Mesh.Normals.ComputeNormals()also.

it works here.

Did you understand that Grasshopper is working on a copy of the Rhino object? So if you make modification on the object you’ll have to bake it in Rhino to have it modified. So you’ll have 2 objects in Rhino.


It’s weird. mesh.flip() works in grasshopper but it didn’t work in RhinoCommon.
Pls, see my code in RhinoCommon. it doesn’t work.


What do you call Rhinocommon. Inside Grasshopper it is Rhinocommon.
Do you you mean working with RhinoCommon inside Visual Studio ?
Does item.Mesh() return a reference or a new mesh.
How can you know the mesh is not flipped ?

It is very hard to decipher your problem with limited informations.

RhinoCommon plug-in for Rhinoceros 6. :blush:
Mesh.flip didn’t return any new or reference mesh. :cold_face: :cold_face:


Hi @hk11,

If you are writing a plug-in command, then this will work:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  var go = new GetObject();
  go.SetCommandPrompt("Select solid mesh");
  go.GeometryFilter = ObjectType.Mesh;
  go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedMesh;
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  var objref = go.Object(0);
  var mesh = objref.Mesh();
  if (null == mesh)
    return Result.Failure;

  if (mesh.SolidOrientation() < 0)
    var mesh_copy = mesh.DuplicateMesh();
    mesh_copy.Flip(true, true, true);
    doc.Objects.Replace(objref, mesh_copy);

  return Result.Success;

– Dale

Thank you, Dale. I got right result now!