# Reverse surface normals (Like Dir command)

**URL:** <https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084>\
**Category:** Rhino Developer\
**Created:** [November 25, 2016, 2:12pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084 "2016-11-25T14:12:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [November 25, 2016, 2:12pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/1 "2016-11-25T14:12:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [November 25, 2016, 3:13pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/2 "2016-11-25T15:13:23Z")

</div>

Hi,

Does Brep.Flip work for you?  
[http://developer.rhino3d.com/api/RhinoCommon/html/M\_Rhino\_Geometry\_Brep\_Flip.htm](http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Flip.htm)

-Willem

---

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [November 25, 2016, 3:57pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/3 "2016-11-25T15:57:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [November 25, 2016, 4:08pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/4 "2016-11-25T16:08:21Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![menno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/menno/32/770384_2.png) [@menno](https://discourse.mcneel.com/u/menno)\
**Post date:** [November 25, 2016, 5:20pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/5 "2016-11-25T17:20:51Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [November 25, 2016, 5:45pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/6 "2016-11-25T17:45:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [November 25, 2016, 5:47pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/7 "2016-11-25T17:47:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![menno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/menno/32/770384_2.png) [@menno](https://discourse.mcneel.com/u/menno)\
**Post date:** [November 26, 2016, 6:00pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/8 "2016-11-26T18:00:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [November 30, 2016, 8:27pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/10 "2016-11-30T20:27:19Z")

</div>

@menno, [BrepFace.OrientationIsReversed](http://developer.rhino3d.com/api/RhinoCommonWin/html/P_Rhino_Geometry_BrepFace_OrientationIsReversed.htm) 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](http://docs.mcneel.com/rhino/5/help/en-us/commands/dir.htm) command, then use [Rhino.Geometry.Brep.Flip](http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_Brep_Flip.htm).

If you have a closed Brep, you may want to check the overall orientation, using [Rhino.Geometry.Brep.SolidOrientation](http://developer.rhino3d.com/api/RhinoCommonWin/html/P_Rhino_Geometry_Brep_SolidOrientation.htm), before flipping.

> [@Yopy\_Hi\_del\_Cano](#):
>
> …but in everycase the Trim result was the same…

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

– Dale

---

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [December 5, 2016, 11:21am UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/11 "2016-12-05T11:21:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [December 5, 2016, 7:04pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/12 "2016-12-05T19:04:05Z")

</div>

> [@Yopy\_Hi\_del\_Cano](#):
>
> Flip the second sphere and then use Brep.Trim; but it did not work.

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

– Dale

---

<div class="post-metadata">

**Author:** ![Yopy\_Hi\_del\_Cano](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yopy_hi_del_cano/32/64521_2.png) [@Yopy\_Hi\_del\_Cano](https://discourse.mcneel.com/u/Yopy_Hi_del_Cano)\
**Post date:** [January 9, 2017, 4:18pm UTC](https://discourse.mcneel.com/t/reverse-surface-normals-like-dir-command/39084/13 "2017-01-09T16:18:12Z")

</div>

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.
