Extruding rectangle creates inside-out result

Can anyone tell me why when I extrude a closed curve such as a rectangle, the result is “inside-out” (the backfaces face outwards)? Doesn’t make much sense to me…

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

r=rs.GetRectangle()  #draw a rectangle in the Top viewport

Thanks, --Mitch

Hi @Helvetosaur,

Clearly, Surface.CreateExtrusion is sensitive to the direction of the path curve, as evident adding this:


Here is an alternate way of creating an extruded rectangle.

r = rs.GetRectangle()
c0 = Rhino.Geometry.PolylineCurve([r[0],r[1],r[2],r[3],r[0]])
dir = Rhino.Geometry.Vector3d(0, 0, 10)
c1 = Rhino.Geometry.LineCurve(r[0], r[0] + dir)
sum = Rhino.Geometry.SumSurface.Create(c0, c1)

– Dale

I think what’s happening is that the Surface.CreateExtrusion() method is too general and doesn’t assume anything about your curves being planar or the orientation of your base plane.

E.g. it works fine with non-planar curves being extruded in arbitrary directions, in which case there is no well-defined way to determine which side of the surface should be the inside/outside.

If you use Rhino.Geometry.Extrusion.Create instead, where it restricts you to planar curves and perpendicular extrusion directions, that should give you consistent results with closed curves.

Well, this was more a question of principle rather than ‘how-to’… I just expected that Surface.CreateExtrusion would have more ‘intelligence’ built-in when it encounters a closed, planar curve that is made according to the “counterclockwise direction” convention… The Rhino command ExtrudeCrv does.

Problem is sometimes I don’t want to extrude in the curve plane normal direction…


Hi Mitch

Well, speaking in general, not about this particular case only, I like that the library functions that we use in our scripts be low-level, simple tools.
That way we have no imposed unneeded calculations (with the time they require).
Also, a simple tool can be more useful in different situation, we can use it in different ways, for different purposes, without having to worry about ‘built-in intelligence’ of any kind.
I think that If a tool assumes too much about what you want to do, sooner or later you’ll have to fight against it to force it to work differently. :wink:

… Just my very humble opinion. :slight_smile:


I agree with you in general @emilio but in this particular case, the tool is required to choose a side for the surface normals in any case; it obviously does not choose a side randomly, as it always creates the same result with any closed ccw direction curve. IMO it works against the ‘convention’ that ccw direction curves are considered “positive” and thus I would expect the normals to point to the outside by default.

…Just my very humble opinion as well… :stuck_out_tongue_closed_eyes:

Cheers, --Mitch

As an additional data point: here is how ExtrudeCrv in Rhino handles non-perpendicular extrusion directions:

And Grasshopper too:

So if anything, changing the underlying workings of Surface.CreateExtrusion would likely break a lot of existing scripts and definitions, even if it would make more sense.

Yep, the Titanic :ship: has sailed…

If it’s helpful, I guess you could think of the orientation being determined by the ‘missing’ cap surface defined by the boundary surface of the original curves

Which can be seen to point upwards/inwards of the volume by the CCW convention. (no clue if that’s how it actually works)