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
plc=Rhino.Geometry.PolylineCurve([r[0],r[1],r[2],r[3],r[0]])
ex_vec=Rhino.Geometry.Vector3d(0,0,10)
ext=Rhino.Geometry.Surface.CreateExtrusion(plc,ex_vec)
sc.doc.Objects.AddSurface(ext)
sc.doc.Views.Redraw()
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.
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…
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.
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.
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.
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