# Reverse surface normals (Like Dir command)

Hi,

Is there a way to reverse a surface normals?
Let’s say for the Brep.Trim function to work properly or to change the result of a BooleanUnion

Regards

Hi,

Does Brep.Flip work for you?
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Flip.htm

-Willem

Hi Willem,

Thank for the fast reply… but it didn’t work for the Brep.Trim
Let’s explain my case in an example:

• I have and sphere, I want to open an spherical hole using another sphere and the Brep.Trim.
• My first try was the Brep.Flip and it didn’t work.

Any other idea?

Hi,

Without testing I might be in the wrong, but I suppose the sphere being a closed surface prevents you from flipping the brep…
You could test with a plane surface to make sure this assumption is correct.

As you can read on the docs for Brep.Trim [here] the inside will indeed be kept.(http://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Brep_Trim.htm)

I suppose you could either use an open spherical surface or resort to Brep.Split and filter out the part you want to keep.

-Willem

TL;DR: I think you may want to use `BrepFace.IsOrientationReversed` (see http://developer.rhino3d.com/api/RhinoCommonWin/html/P_Rhino_Geometry_BrepFace_OrientationIsReversed.htm

The situation with normals and polysurfaces is a bit complex, but I’ll try to explain. A surface has one normal direction, which is defined as the vector product of the tangents in U- and V-direction. Therefore the normal is determined by the direction of U and V (which can be changed by the `Dir` command by the way).
But when a surface becomes part of a Brep (polysurface, or trimmed) the normal of a BrepFace can be flipped independently of the underlying surface using the property mentioned above.
If you think about it, it is quite logical to have this, because it is much easier to do this, than to change the surface directions (because that also means you need to change the trim definitions!).

You can see this `IsOrientationReversed` also if you look carefully to a surface whose normal has been flipped: it has a purple line opposite of the direction arrow. See also the documentation of the Dir command, where this is also explained.

The final kicker is this: even untrimmed surfaces are Breps in the Rhino document. So you can flip the orientation of a surface but leave its directions intact.

Willem,
I’ll try what you’ve mentioned ‘use the plane’… I’ll let you know.

Menno,

The property OrientationIsReversed appeared to me ‘ReadOnly’, in any case, I checked with the method Flip and it OrientationIsReversed changed every time, but in everycase the Trim result was the same

Oh that’s weird, because the documentation says it has a public setter. You may not be on the latest version/sr.

@menno, BrepFace.OrientationIsReversed is a public property (get and set). The property returns true if the Brep face’s orientation is opposite of natural, underlying surface orientation.

@Yopy_Hi_del_Cano, if you want to reverse surface normal like Rhino’s Dir command, then use Rhino.Geometry.Brep.Flip.

If you have a closed Brep, you may want to check the overall orientation, using Rhino.Geometry.Brep.SolidOrientation, before flipping.

I am not sure I understand what this means. Can you provide more information? Are you having a problem performing a Boolean operation?

– Dale

Hi Dale,

Double checking Rhino.Geometry.Brep.Flip functionality seems to work fine.

But the problem appears when:

• I have and sphere, I want to trim it using another sphere. According to the documentation, I’d only need to Flip the second sphere and then use Brep.Trim; but it did not work.

The fact is that I don’t want to use a Boolean operation because if I do, then I’ll have to deal with another face inside the Brep, and I just don’t want that.

This is a know issue with Rhino 5, and this has been fixed in the Rhino WIP.

– Dale

Sorry Dale,

I keep on working on the project I was stuck with another solution, as soon as I have time I’ll check it out with the WIP.