I found myself caught by a brep with faces that have a reversed orientations.
What I like to do is correct the breps so all faces are oriented naturally.
My fix seems to work, but I’d like to verify if this approach is correct:
def purge_orientationreversions(objs):
for obj in objs:
brep = rs.coercebrep(obj)
for face in brep.Faces:
if face.OrientationIsReversed:
face.Reverse(0,True)
sc.doc.Objects.Replace(obj,brep)
Is the approach above wise and effective in all cases?
I do not want to flip any faces, the faces are oriented in the right direction.
However if I query planarity with BrepFace.TryGetPlane(), it seems the underlying surface’s plane is returned.
That is not valid for my purpose as it’s opposed to the face orientation.
I tried to reverse this plane for reversed faces, however it seems somewhere downstream the reversal still causes unexpected results.
I have a workflow to orient breps in specific alignments. These are all non-solid objects; breps with one or more faces. The current face orientations are correct - be it that some have reversed orientations based on the underlying surfaces-
Somewhere in this workflow the reversed orientation is causing a misalignment.
I have been digging for a while to see if I could track down the cause but to no avail.
It was only today that I thought of checking the face orientation reversal.
If I reverse the face in U direction, the workflow is aligning these breps correctly.
I have still no idea what the reason is, it might be a face normal is found reversed or a plane is ‘wronghanded’.
In any case my thinking is that sanitizing my input will ensure a correct workflow regardless.
The RemoveFlippedNormals command is a test command, which is why it does not auto-complete.
To perform the same action in RhinoCommon as this command, use the BrepFaceList.Flip method and pass a True value in for the onlyReverseFaces parameter.