How to fix reversed face orientations


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:

Is the approach above wise and effective in all cases?


Hi @Willem,

Why? What problem does this solve?

Note, BrepFace.Reverse changes the surface domain from [a,b] to [-b,-a]. If you want to ‘flip’ the orientation of the face, then just do this:

face.OrientationIsReversed = False

If the goal is to ensure solids have their face normal pointing outwards, then you can do something like this:

def TestSolidOrientation(objs):
    num_flipped = 0
    for obj in objs:
        brep = rs.coercebrep(obj)
        if brep and brep.IsSolid:
            if brep.SolidOrientation == Rhino.Geometry.BrepSolidOrientation.Inward:
                sc.doc.Objects.Replace(obj, brep)
                num_flipped += 1
    return num_flipped      

– Dale

1 Like

Hi @dale,

Thanks for the reply.

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.


@Willem, just curious, does it fix the flipped plane normals if you run _RemoveFlippedNormals before ?


Hi Clement,

Yes, this fixes the reversed faces indeed.

The command was depricated per V5 so it does not autocomplete.
I dug up the V4 help on the command and it appears to operate on the underlying surface, adjusting UV directions.


p.s. @Dale if you have time to share any more insight in this please do so.

Hi @Willem,

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.

– Dale