Brep Solid Orientation Bug?

Hi,

I have a solid Brep with surface normals pointing inwards, but it shows “Outward” when I print out its SolidOrientation property using RhinoCommon. Also, I tried using Brep.Flip(), which changed its solid orientation property to “Inward” but didn’t change the normal directions. Has anybody had this problem before?

Thanks,
Yao
231120_solid_orientation_bug.3dm (190.0 KB)
231120_solid_orientation_bug.gh (4.0 KB)

Hi @Yao,

Brep.SolidOrientation does not return a bool.

This is better:

private void RunScript(Brep brep, ref object A)
{
  if (null != brep && brep.IsValid)
  {
    if (BrepSolidOrientation.Inward == brep.SolidOrientation)
      brep.Flip();
  }
  A = brep;
}

– Dale

1 Like

Hi @dale ,

Thank you very much for the answer.

Yes, I am aware that Brep.SolidOrientation returns an Enum.

Yes, I have been doing this without any problem until today. Please see the attached 3dm and gh files for the problematic Brep. I don’t know what is special about it that makes Brep.Flip() not working. Any insights would be very helpful. Thank you!

Regards,
Yao

1 Like

If I do this just in Rhino with the Flip command, the command won’t let me because “Cannot flip a closed solid”. This is most likely the same reason that brep.Flip() does not work, but you don’t get any feedback.

Select the BRep, then Explode SelLast Flip Join does flip the closed BRep. You should emulate this in code to achieve the same result I think.

What would be nice if void Brep.Flip() was actually bool brep.Flip(out error) giving you the same feedback on success of the flip operation and a reason why it did not work in the error variable.

1 Like

Hi @menno,

Thanks for the idea. Yes, this would work.

Now I have many closed breps (all generated by extruding a curve profile and then cap planner holes) and a few of them have flipped normals. I wanted to use brep.SolidOrientation to check whether they are inside out, but it doesn’t give me the correct result for some breps. I wanted to know why this is happening and if this is a bug or not. Hi @dale, could you please provide any insights?

Thank you both very much!

Yao

Hi @Yao,

How are you creating these closed Breps? Do you have sample code that creates the problematic ones?

– Dale

Hi @dale,

I extruded rectangles into square tubes and then capped the end holes. Yes, I do have the sample code in a .gh file.
solid_orientation_bug.gh (22.7 KB)

When I bake the outputs, some breps are inside out like this:

And here is my system info:
solid_orientation_bug_system_info.txt (2.9 KB)

Thank you very much for your time!

Yao

Hi @Yao,

Please review the following changes and let me know if you have any questions.

solid_orientation_fixed.gh (22.9 KB)

– Dale

1 Like

Amazing! Thank you very much for the edits as well as the detailed explanations!