discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

extruding 2D objects that have been moved off of the Z=0 plane

JB
Jordan Brown
Thu, Aug 7, 2025 11:29 PM

In looking at the documentation of extrusion, I see that there's a fair
amount of complex text about what happens when you try to extrude
(either linearly or rotationally) a 2D shape that has been moved off of
the Z=0 plane, and in particular one that has been rotated so that it is
no longer parallel to the Z=0 plane.

My personal opinion is "don't do that".  You should only extrude vanilla
2D objects that are on the Z=0 plane.

I'd prefer that we treated that case as an error.

In addition to avoiding the need to explain the behavior, that would in
the future allow us to do things like have an extrusion of an off-axis
2D object extrude in the direction of its local Z axis, which would seem
like a more obvious interpretation. (Though not enormously more useful,
since you could always do the rotation after extruding.)

What do people think?  Does anybody depend on this oddball behavior?

In looking at the documentation of extrusion, I see that there's a fair amount of complex text about what happens when you try to extrude (either linearly or rotationally) a 2D shape that has been moved off of the Z=0 plane, and in particular one that has been rotated so that it is no longer parallel to the Z=0 plane. My personal opinion is "don't do that".  You should only extrude vanilla 2D objects that are on the Z=0 plane. I'd prefer that we treated that case as an error. In addition to avoiding the need to explain the behavior, that would in the future allow us to do things like have an extrusion of an off-axis 2D object extrude in the direction of its local Z axis, which would seem like a more obvious interpretation. (Though not enormously more useful, since you could always do the rotation *after* extruding.) What do people think?  Does anybody depend on this oddball behavior?
V
vulcan_@mac.com
Fri, Aug 8, 2025 12:26 AM

are you requesting a change in the docs? or a change in the code?

are you requesting a change in the docs? or a change in the code?
BC
Bob Carlson
Fri, Aug 8, 2025 12:27 AM

I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter!

-Bob

On Aug 7, 2025, at 16:29, Jordan Brown via Discuss discuss@lists.openscad.org wrote:

In looking at the documentation of extrusion, I see that there's a fair amount of complex text about what happens when you try to extrude (either linearly or rotationally) a 2D shape that has been moved off of the Z=0 plane, and in particular one that has been rotated so that it is no longer parallel to the Z=0 plane.

My personal opinion is "don't do that".  You should only extrude vanilla 2D objects that are on the Z=0 plane.

I'd prefer that we treated that case as an error.

In addition to avoiding the need to explain the behavior, that would in the future allow us to do things like have an extrusion of an off-axis 2D object extrude in the direction of its local Z axis, which would seem like a more obvious interpretation. (Though not enormously more useful, since you could always do the rotation after extruding.)

What do people think?  Does anybody depend on this oddball behavior?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter! -Bob > On Aug 7, 2025, at 16:29, Jordan Brown via Discuss <discuss@lists.openscad.org> wrote: > > In looking at the documentation of extrusion, I see that there's a fair amount of complex text about what happens when you try to extrude (either linearly or rotationally) a 2D shape that has been moved off of the Z=0 plane, and in particular one that has been rotated so that it is no longer parallel to the Z=0 plane. > > My personal opinion is "don't do that". You should only extrude vanilla 2D objects that are on the Z=0 plane. > > I'd prefer that we treated that case as an error. > > In addition to avoiding the need to explain the behavior, that would in the future allow us to do things like have an extrusion of an off-axis 2D object extrude in the direction of its local Z axis, which would seem like a more obvious interpretation. (Though not enormously more useful, since you could always do the rotation *after* extruding.) > > > What do people think? Does anybody depend on this oddball behavior? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Fri, Aug 8, 2025 8:04 AM

On 8/7/2025 5:26 PM, vulcan_--- via Discuss wrote:

are you requesting a change in the docs? or a change in the code?

Requesting may be too strong a word.  It is premature to make any change
to either.

Rather, I'm collecting opinions on the subject.

My opinion is that we should disallow extrusion of 2D objects that have
been moved in any way off of the Z=0 plane, and then of course the
documentation would change to match.  (And the, having disallowed it, we
could eventually re-allow it with different semantics, when and if
somebody has the interest in doing the work.)  But there needs to be
consensus first.

On 8/7/2025 5:26 PM, vulcan_--- via Discuss wrote: > > are you requesting a change in the docs? or a change in the code? > Requesting may be too strong a word.  It is premature to make any change to either. Rather, I'm collecting opinions on the subject. My opinion is that we should disallow extrusion of 2D objects that have been moved in any way off of the Z=0 plane, and then of course the documentation would change to match.  (And the, having disallowed it, we could eventually re-allow it with different semantics, when and if somebody has the interest in doing the work.)  But there needs to be consensus first.
RD
Revar Desmera
Fri, Aug 8, 2025 8:25 AM

On Aug 8, 2025, at 1:04 AM, Jordan Brown via Discuss discuss@lists.openscad.org wrote:

On 8/7/2025 5:26 PM, vulcan_--- via Discuss wrote:

are you requesting a change in the docs? or a change in the code?

Requesting may be too strong a word.  It is premature to make any change to either.

Rather, I'm collecting opinions on the subject.

My opinion is that we should disallow extrusion of 2D objects that have been moved in any way off of the Z=0 plane, and then of course the documentation would change to match.  (And the, having disallowed it, we could eventually re-allow it with different semantics, when and if somebody has the interest in doing the work.)  But there needs to be consensus first.

The only time I can sort of see a use for moving a 2D shape off of the Z=0 plane, might be for a notional operation where one does a projection(cut=false) with the idea of getting the "shadow" of a rotated 2D shape on the Z=0 plane.  Kiiiiiiiiinda dodgy, though.

Mayyyyyyybe a linear_extrude() could extrude said shadow, but that seems extra skeevy.

I cannot see a sensible use of rotate_extrude() with a 2D shape off of Z=0, though.

  • Revar
> On Aug 8, 2025, at 1:04 AM, Jordan Brown via Discuss <discuss@lists.openscad.org> wrote: > > On 8/7/2025 5:26 PM, vulcan_--- via Discuss wrote: >> >> are you requesting a change in the docs? or a change in the code? >> > Requesting may be too strong a word. It is premature to make any change to either. > > Rather, I'm collecting opinions on the subject. > > My opinion is that we should disallow extrusion of 2D objects that have been moved in any way off of the Z=0 plane, and then of course the documentation would change to match. (And the, having disallowed it, we could eventually re-allow it with different semantics, when and if somebody has the interest in doing the work.) But there needs to be consensus first. The only time I can sort of see a use for moving a 2D shape off of the Z=0 plane, might be for a notional operation where one does a `projection(cut=false)` with the idea of getting the "shadow" of a rotated 2D shape on the Z=0 plane. Kiiiiiiiiinda dodgy, though. Mayyyyyyybe a linear_extrude() could extrude said shadow, but that seems extra skeevy. I cannot see a sensible use of rotate_extrude() with a 2D shape off of Z=0, though. - Revar
JB
Jordan Brown
Fri, Aug 8, 2025 8:52 AM

On 8/8/2025 1:25 AM, Revar Desmera via Discuss wrote:

The only time I can sort of see a use for moving a 2D shape off of the Z=0 plane,

I not-infrequently move 2D objects off of the Z=0 plane, perversely when
I am making 2D diagrams.

Moving objects +Z lets me "stack" them and make colors cleanly visible. 
Since the goal in that case is to generate a 2D diagram, I usually don't
bother extruding.

E.g.

s = "Hello";
tm = textmetrics(s);
translate(tm.position) square(tm.size);
color("black") translate([0,0,1]) text(s);

View from directly +Z.

But that doesn't require extruding those wandering 2D objects.

It occurs to me that extruding to different heights is about the same
level of additional noise as translating to different heights, so that's
an alternative pattern.  Still, there may be legacy uses.  But that's
why I was suggesting restricting extrusion, not restricting transformation.

On 8/8/2025 1:25 AM, Revar Desmera via Discuss wrote: > The only time I can sort of see a use for moving a 2D shape off of the Z=0 plane, I not-infrequently move 2D objects off of the Z=0 plane, perversely when I am making 2D diagrams. Moving objects +Z lets me "stack" them and make colors cleanly visible.  Since the goal in that case is to generate a 2D diagram, I usually don't bother extruding. E.g. s = "Hello"; tm = textmetrics(s); translate(tm.position) square(tm.size); color("black") translate([0,0,1]) text(s); View from directly +Z. But that doesn't require *extruding* those wandering 2D objects. It occurs to me that extruding to different heights is about the same level of additional noise as translating to different heights, so that's an alternative pattern.  Still, there may be legacy uses.  But that's why I was suggesting restricting extrusion, not restricting transformation.
JB
Jordan Brown
Fri, Aug 8, 2025 9:01 AM

On 8/7/2025 5:27 PM, Bob Carlson wrote:

I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter!

Maybe I'm missing something, but ISTM that getting the 2D shape into the
right orientation would involve exactly the same rotations as getting
the extruded 3D shape into the right orientation does.

If you want an extrusion along the +X axis, you need to rotate([0,90,0])
somewhere, even with semantics that support extruding a 2D shape that's
been lifted off of Z=0.  You would need either "linear_extrude(...)
rotate([0,90,0]) square(...)" or "rotate([0,90,0]) linear_extrude(...)
square(...)".

On 8/7/2025 5:27 PM, Bob Carlson wrote: > I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter! Maybe I'm missing something, but ISTM that getting the 2D shape into the right orientation would involve exactly the same rotations as getting the extruded 3D shape into the right orientation does. If you want an extrusion along the +X axis, you need to rotate([0,90,0]) somewhere, even with semantics that support extruding a 2D shape that's been lifted off of Z=0.  You would need either "linear_extrude(...) rotate([0,90,0]) square(...)" or "rotate([0,90,0]) linear_extrude(...) square(...)".
V
vulcan_@mac.com
Sat, Aug 9, 2025 12:19 AM

so .. if i want an extruded shape transformed off of the Z=0 plane i could just apply translations and rotations to the linear_extrusion() child, right?

so to look like i was extruding along the X azis

rotate( [0,90,0 ])
linear_extrude(height=30 )
circle( 5 );

would do it.

so .. if i want an extruded shape transformed off of the Z=0 plane i could just apply translations and rotations to the linear_extrusion() child, right? so to look like i was extruding along the X azis `rotate( [0,90,0 ])`\ ` linear_extrude(height=30 )`\ ` circle( 5 );` would do it.
BC
Bob Carlson
Sat, Aug 9, 2025 10:14 PM

It does not come up when I am using 2D primitives. When I need a part that has a particular cross section (in say the y = 0 plane, extrusion is along Y) I often create that cross section using a path of points. I am thinking of that cross section in terms of [x, 0, z]. My brain just cannot translate that to an [x, y] path without a lot of difficulty. When I do, my brain cannot see intuitively what combination of rotation and spin are required after a Z extrude. I spent many minutes just constructing the rotation, spin and translation that I need to get it into the orientation I need. If I can define my 2D path in 3D space and the extrude along the normal, it way less taxing. Sometimes I will even define the 2D outline in 3D space twice, extruded tiny slices and translate one along the normal and then hull() it. It takes less mental time to do that than to use Z extrusion and figure out all the rest.

Extruding along a normal to a 2D figure in 3D space seems pretty intuitive to me, at least when one dimension is constant, as opposed to a random orientation of the 2D figure. I suppose one could ask, which normal? Up or down? Right hand rule I suppose.

-Bob

On Aug 8, 2025, at 02:01, Jordan Brown openscad@jordan.maileater.net wrote:

On 8/7/2025 5:27 PM, Bob Carlson wrote:

I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter!

Maybe I'm missing something, but ISTM that getting the 2D shape into the right orientation would involve exactly the same rotations as getting the extruded 3D shape into the right orientation does.

If you want an extrusion along the +X axis, you need to rotate([0,90,0]) somewhere, even with semantics that support extruding a 2D shape that's been lifted off of Z=0.  You would need either "linear_extrude(...) rotate([0,90,0]) square(...)" or "rotate([0,90,0]) linear_extrude(...) square(...)".

It does not come up when I am using 2D primitives. When I need a part that has a particular cross section (in say the y = 0 plane, extrusion is along Y) I often create that cross section using a path of points. I am thinking of that cross section in terms of [x, 0, z]. My brain just cannot translate that to an [x, y] path without a lot of difficulty. When I do, my brain cannot see intuitively what combination of rotation and spin are required after a Z extrude. I spent many minutes just constructing the rotation, spin and translation that I need to get it into the orientation I need. If I can define my 2D path in 3D space and the extrude along the normal, it way less taxing. Sometimes I will even define the 2D outline in 3D space twice, extruded tiny slices and translate one along the normal and then hull() it. It takes less mental time to do that than to use Z extrusion and figure out all the rest. Extruding along a normal to a 2D figure in 3D space seems pretty intuitive to me, at least when one dimension is constant, as opposed to a random orientation of the 2D figure. I suppose one could ask, which normal? Up or down? Right hand rule I suppose. -Bob > On Aug 8, 2025, at 02:01, Jordan Brown <openscad@jordan.maileater.net> wrote: > > > On 8/7/2025 5:27 PM, Bob Carlson wrote: >> I agree, but I would find the alternate interpretation extremely useful. I find it very time consuming and confusing to use extrusion when the part is to used in something other than the Z axis. Being able to define my 2D shape in the plane where it needs to end up would save me lots of time and brain power! Both are limited! Especially the latter! > > Maybe I'm missing something, but ISTM that getting the 2D shape into the right orientation would involve exactly the same rotations as getting the extruded 3D shape into the right orientation does. > > If you want an extrusion along the +X axis, you need to rotate([0,90,0]) somewhere, even with semantics that support extruding a 2D shape that's been lifted off of Z=0. You would need either "linear_extrude(...) rotate([0,90,0]) square(...)" or "rotate([0,90,0]) linear_extrude(...) square(...)". > >
BC
Bob Carlson
Mon, Aug 11, 2025 5:01 PM

On Aug 10, 2025, at 08:55, Jordan Brown openscad@jordan.maileater.net wrote:

On 8/9/2025 10:14 PM, Bob Carlson wrote:

I am thinking of that cross section in terms of [x, 0, z].

OK.  That would require that polygon() allow you to specify points in 3-space, which it currently does not allow.  Right?

Right

(And then there would be questions about getting the points to be coplanar, which is easy to do precisely if you're axis-aligned, but less easy if not.)

I’ve never run into a case where I would not be aligned with one axis or another.

Sounds like fodder for OEP7: Mixed Dimension Geometry Support https://github.com/openscad/openscad/wiki/OEP7:-Mixed-Dimension-Geometry-Support, if anybody ever takes that on.

It does not sound like you care about the case where you've created something using the 2D primitives (and so it lies in the Z=0 plane) and you've then moved the 2D object out of the Z=0 plane and extruded it.  Right?

Correct

I haven’t thought thru this, but a module that took my 2Din3D shape, moved it to XY, extruded it and moved it back, might be pretty straight forward.

-Bob

> On Aug 10, 2025, at 08:55, Jordan Brown <openscad@jordan.maileater.net> wrote: > > On 8/9/2025 10:14 PM, Bob Carlson wrote: >> I am thinking of that cross section in terms of [x, 0, z]. > OK. That would require that polygon() allow you to specify points in 3-space, which it currently does not allow. Right? > Right > (And then there would be questions about getting the points to be coplanar, which is easy to do precisely if you're axis-aligned, but less easy if not.) > I’ve never run into a case where I would not be aligned with one axis or another. > Sounds like fodder for OEP7: Mixed Dimension Geometry Support <https://github.com/openscad/openscad/wiki/OEP7:-Mixed-Dimension-Geometry-Support>, if anybody ever takes that on. > > It does *not* sound like you care about the case where you've created something using the 2D primitives (and so it lies in the Z=0 plane) and you've then moved the 2D object out of the Z=0 plane and extruded it. Right? > Correct I haven’t thought thru this, but a module that took my 2Din3D shape, moved it to XY, extruded it and moved it back, might be pretty straight forward. -Bob