discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

folding

JB
Jon Bondy
Sun, Nov 23, 2025 8:21 PM

Does anyone know of a library that will take a 2D object and fold it at
a specified angle along a specified line?

Thanks

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Does anyone know of a library that will take a 2D object and fold it at a specified angle along a specified line? Thanks Jon -- This email has been checked for viruses by AVG antivirus software. www.avg.com
NS
Nathan Sokalski
Sun, Nov 23, 2025 11:30 PM

Is there any way of combining several intersect() & rotate() statements with (possibly multiple) instances of your 2d object to get what you want? Depending on your final goal you may also want to throw in a linear_extrude()

Nathan Sokalski
njsokalski@hotmail.commailto:njsokalski@hotmail.com


From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Sunday, November 23, 2025 3:21 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] folding

Does anyone know of a library that will take a 2D object and fold it at
a specified angle along a specified line?

Thanks

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.comhttp://www.avg.com


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

Is there any way of combining several intersect() & rotate() statements with (possibly multiple) instances of your 2d object to get what you want? Depending on your final goal you may also want to throw in a linear_extrude() Nathan Sokalski njsokalski@hotmail.com<mailto:njsokalski@hotmail.com> ________________________________ From: Jon Bondy via Discuss <discuss@lists.openscad.org> Sent: Sunday, November 23, 2025 3:21 PM To: OpenSCAD general discussion <discuss@lists.openscad.org> Cc: Jon Bondy <jon@jonbondy.com> Subject: [OpenSCAD] folding Does anyone know of a library that will take a 2D object and fold it at a specified angle along a specified line? Thanks Jon -- This email has been checked for viruses by AVG antivirus software. www.avg.com<http://www.avg.com> _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jon Bondy
Sun, Nov 23, 2025 11:36 PM

In the end, that is exactly what I did, Nathan, but the idea in my head
was much simpler than the code that resulted.  And the "folds" are not
very pretty.  Functional, though.

On 11/23/2025 6:30 PM, Nathan Sokalski via Discuss wrote:

Is there any way of combining several intersect() & rotate()
statements with (possibly multiple) instances of your 2d object to get
what you want? Depending on your final goal you may also want to throw
in a linear_extrude()

Nathan Sokalski
njsokalski@hotmail.com

From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Sunday, November 23, 2025 3:21 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] folding
Does anyone know of a library that will take a 2D object and fold it at
a specified angle along a specified line?

Thanks

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFAg&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=jQKjF7R29Hhsk30DPDsfM61UszUgumOxliPbggZwgKmmX3kN23e03Co6Gdz13JRo&s=64oHYvE3J3clL7iwwgrt4t6hPIRpM_Kb6IELL5oyW6I&e=


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


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

In the end, that is exactly what I did, Nathan, but the idea in my head was much simpler than the code that resulted.  And the "folds" are not very pretty.  Functional, though. On 11/23/2025 6:30 PM, Nathan Sokalski via Discuss wrote: > Is there any way of combining several intersect() & rotate() > statements with (possibly multiple) instances of your 2d object to get > what you want? Depending on your final goal you may also want to throw > in a linear_extrude() > > Nathan Sokalski > njsokalski@hotmail.com > ------------------------------------------------------------------------ > *From:* Jon Bondy via Discuss <discuss@lists.openscad.org> > *Sent:* Sunday, November 23, 2025 3:21 PM > *To:* OpenSCAD general discussion <discuss@lists.openscad.org> > *Cc:* Jon Bondy <jon@jonbondy.com> > *Subject:* [OpenSCAD] folding > Does anyone know of a library that will take a 2D object and fold it at > a specified angle along a specified line? > > Thanks > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFAg&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=jQKjF7R29Hhsk30DPDsfM61UszUgumOxliPbggZwgKmmX3kN23e03Co6Gdz13JRo&s=64oHYvE3J3clL7iwwgrt4t6hPIRpM_Kb6IELL5oyW6I&e=> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
NH
nop head
Sun, Nov 23, 2025 11:43 PM

You probably want to also specify the bend radius and rotate_extrude a
curve at the fold line.

On Sun, 23 Nov 2025 at 23:36, Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:

In the end, that is exactly what I did, Nathan, but the idea in my head
was much simpler than the code that resulted.  And the "folds" are not very
pretty.  Functional, though.

On 11/23/2025 6:30 PM, Nathan Sokalski via Discuss wrote:

Is there any way of combining several intersect() & rotate() statements
with (possibly multiple) instances of your 2d object to get what you want?
Depending on your final goal you may also want to throw in a
linear_extrude()

Nathan Sokalski
njsokalski@hotmail.com

From: Jon Bondy via Discuss discuss@lists.openscad.org
discuss@lists.openscad.org
Sent: Sunday, November 23, 2025 3:21 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com jon@jonbondy.com
Subject: [OpenSCAD] folding

Does anyone know of a library that will take a 2D object and fold it at
a specified angle along a specified line?

Thanks

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFAg&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=jQKjF7R29Hhsk30DPDsfM61UszUgumOxliPbggZwgKmmX3kN23e03Co6Gdz13JRo&s=64oHYvE3J3clL7iwwgrt4t6hPIRpM_Kb6IELL5oyW6I&e=


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


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

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
Virus-free.www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
<#m_1724404372601329259_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


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

You probably want to also specify the bend radius and rotate_extrude a curve at the fold line. On Sun, 23 Nov 2025 at 23:36, Jon Bondy via Discuss < discuss@lists.openscad.org> wrote: > In the end, that is exactly what I did, Nathan, but the idea in my head > was much simpler than the code that resulted. And the "folds" are not very > pretty. Functional, though. > > > > On 11/23/2025 6:30 PM, Nathan Sokalski via Discuss wrote: > > Is there any way of combining several intersect() & rotate() statements > with (possibly multiple) instances of your 2d object to get what you want? > Depending on your final goal you may also want to throw in a > linear_extrude() > > Nathan Sokalski > njsokalski@hotmail.com > ------------------------------ > *From:* Jon Bondy via Discuss <discuss@lists.openscad.org> > <discuss@lists.openscad.org> > *Sent:* Sunday, November 23, 2025 3:21 PM > *To:* OpenSCAD general discussion <discuss@lists.openscad.org> > <discuss@lists.openscad.org> > *Cc:* Jon Bondy <jon@jonbondy.com> <jon@jonbondy.com> > *Subject:* [OpenSCAD] folding > > Does anyone know of a library that will take a 2D object and fold it at > a specified angle along a specified line? > > Thanks > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFAg&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=jQKjF7R29Hhsk30DPDsfM61UszUgumOxliPbggZwgKmmX3kN23e03Co6Gdz13JRo&s=64oHYvE3J3clL7iwwgrt4t6hPIRpM_Kb6IELL5oyW6I&e=> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > Virus-free.www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > <#m_1724404372601329259_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Tue, Nov 25, 2025 1:48 PM

I can do that for sure, but unfortunately only in python.
Regards

On Mon, 24 Nov, 2025, 1:52 am Jon Bondy via Discuss, <
discuss@lists.openscad.org> wrote:

Does anyone know of a library that will take a 2D object and fold it at
a specified angle along a specified line?

Thanks

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com


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

I can do that for sure, but unfortunately only in python. Regards On Mon, 24 Nov, 2025, 1:52 am Jon Bondy via Discuss, < discuss@lists.openscad.org> wrote: > Does anyone know of a library that will take a 2D object and fold it at > a specified angle along a specified line? > > Thanks > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Tue, Nov 25, 2025 6:38 PM

On 11/23/2025 12:21 PM, Jon Bondy via Discuss wrote:

Does anyone know of a library that will take a 2D object and fold it
at a specified angle along a specified line?

I think I could do it (intersecting with two appropriately-positioned
big cubes, and appropriately rotating the results of one).

However, before I figure out the answer... if you truly mean a 2D
object, you're getting into a weird area:  2D objects that are not on
the Z=0 plane.  OpenSCAD will do such operations, and will display
something sensible, but after that there isn't much that you can do with
them.  As 2D objects, you can only export them to 2D formats, which
won't be all that useful no matter what it does.  (And I think what it
will do is project back down to Z=0.)

So what are you really trying do to?  If you're just trying to visualize
the results, I can work it out for you.  If it's something more than
that, then we'd need to talk about the details.

Also note:  folding one 2D object is more or less straightforward. 
But folding it again is much less straightforward, as the big cubes
for subsequent folds start intersecting with unintended parts of the model.

On 11/23/2025 12:21 PM, Jon Bondy via Discuss wrote: > Does anyone know of a library that will take a 2D object and fold it > at a specified angle along a specified line? I think I could do it (intersecting with two appropriately-positioned big cubes, and appropriately rotating the results of one). However, before I figure out the answer... if you truly mean a 2D object, you're getting into a weird area:  2D objects that are not on the Z=0 plane.  OpenSCAD will do such operations, and will display something sensible, but after that there isn't much that you can do with them.  As 2D objects, you can only export them to 2D formats, which won't be all that useful no matter what it does.  (And I think what it will do is project back down to Z=0.) So what are you really trying do to?  If you're just trying to visualize the results, I can work it out for you.  If it's something more than that, then we'd need to talk about the details. Also note:  folding *one* 2D object is more or less straightforward.  But folding it *again* is much less straightforward, as the big cubes for subsequent folds start intersecting with unintended parts of the model.
JJ
jon jonbondy.com
Tue, Nov 25, 2025 8:36 PM

Jordan:

Thanks for helping me think about this.

Once I sent the "2D" message, I realized that I really wanted to do it
with 3D objects, but thin ones.  Conceptually 2D, but actually 3D.

This is what I came up with to make the fold.  Crude and ugly, but my
customer needs glasses, so all is good.

I can imagine a general library to do things like this, but I am sure
that there are people on this list who are more sophisticated than I am

eps = 0.01;
slop = 0.2;
$fa = 3;
$fs = 0.2;
inches = 25.4;

// ball diameters
bd25 = 25.3 + slop;
an   = 27;                // angle from vertical to surface of bowl

ct  = 4;        // circle thickness
cd  = 130 - 6;    // circle diameter
cr  = cd/2;        // circle radius
cwa = 52;        // fold angle for circle wings
ca  = 67;        // angle between the wings
ca2 = ca/2;        // half angle between wings

module Circle(d2Fac)
    // d2Fac is 1 for regular cylinder, 0.8 for sharp edges for the wings
    cylinder(h = ct, d1 = cd, d2 = d2Fac*cd);

module Vee() {
    // the vee
    difference() {
        // the circle
        translate([0, cr, 0])
            Circle(1);
        // trim off where the wings will be
        translate([0, 0, -eps])
            rotate([0, 0, -ca2])
                cube([200, 200, ct + 2eps]);
        translate([0, 0, -eps])
            rotate([0, 0, 90 + ca2])
                cube([200, 200, ct + 2
eps]);
        }
    // flap
    // rotated back into place
    rotate([0, 0, -ca2])
    // rotated up in the air
    rotate([0, -cwa, 0])
    // rotated so fold is along Y axis
    rotate([0, 0, ca2])
    // the flap
    intersection() {
        translate([0, cr, 0])
            Circle(0.8);
        translate([0, 0, -eps])
            rotate([0, 0, -ca2])
                cube([200, 200, ct + 2*eps]);
        }
    }
Vee();

On 11/25/2025 1:38 PM, Jordan Brown wrote:

On 11/23/2025 12:21 PM, Jon Bondy via Discuss wrote:

Does anyone know of a library that will take a 2D object and fold it
at a specified angle along a specified line?

I think I could do it (intersecting with two appropriately-positioned
big cubes, and appropriately rotating the results of one).

However, before I figure out the answer... if you truly mean a 2D
object, you're getting into a weird area:  2D objects that are not on
the Z=0 plane.  OpenSCAD will do such operations, and will display
something sensible, but after that there isn't much that you can do
with them.  As 2D objects, you can only export them to 2D formats,
which won't be all that useful no matter what it does.  (And I think
what it will do is project back down to Z=0.)

So what are you really trying do to?  If you're just trying to
visualize the results, I can work it out for you.  If it's something
more than that, then we'd need to talk about the details.

Also note:  folding one 2D object is more or less straightforward. 
But folding it again is much less straightforward, as the big cubes
for subsequent folds start intersecting with unintended parts of the
model.

Jordan: Thanks for helping me think about this. Once I sent the "2D" message, I realized that I really wanted to do it with 3D objects, but thin ones.  Conceptually 2D, but actually 3D. This is what I came up with to make the fold.  Crude and ugly, but my customer needs glasses, so all is good. I can imagine a general library to do things like this, but I am sure that there are people on this list who are more sophisticated than I am eps = 0.01; slop = 0.2; $fa = 3; $fs = 0.2; inches = 25.4; // ball diameters bd25 = 25.3 + slop; an   = 27;                // angle from vertical to surface of bowl ct  = 4;        // circle thickness cd  = 130 - 6;    // circle diameter cr  = cd/2;        // circle radius cwa = 52;        // fold angle for circle wings ca  = 67;        // angle between the wings ca2 = ca/2;        // half angle between wings module Circle(d2Fac)     // d2Fac is 1 for regular cylinder, 0.8 for sharp edges for the wings     cylinder(h = ct, d1 = cd, d2 = d2Fac*cd); module Vee() {     // the vee     difference() {         // the circle         translate([0, cr, 0])             Circle(1);         // trim off where the wings will be         translate([0, 0, -eps])             rotate([0, 0, -ca2])                 cube([200, 200, ct + 2*eps]);         translate([0, 0, -eps])             rotate([0, 0, 90 + ca2])                 cube([200, 200, ct + 2*eps]);         }     // flap     // rotated back into place     rotate([0, 0, -ca2])     // rotated up in the air     rotate([0, -cwa, 0])     // rotated so fold is along Y axis     rotate([0, 0, ca2])     // the flap     intersection() {         translate([0, cr, 0])             Circle(0.8);         translate([0, 0, -eps])             rotate([0, 0, -ca2])                 cube([200, 200, ct + 2*eps]);         }     } Vee(); On 11/25/2025 1:38 PM, Jordan Brown wrote: > On 11/23/2025 12:21 PM, Jon Bondy via Discuss wrote: >> Does anyone know of a library that will take a 2D object and fold it >> at a specified angle along a specified line? > > > I think I could do it (intersecting with two appropriately-positioned > big cubes, and appropriately rotating the results of one). > > However, before I figure out the answer... if you truly mean a 2D > object, you're getting into a weird area:  2D objects that are not on > the Z=0 plane.  OpenSCAD will do such operations, and will display > something sensible, but after that there isn't much that you can do > with them.  As 2D objects, you can only export them to 2D formats, > which won't be all that useful no matter what it does.  (And I think > what it will do is project back down to Z=0.) > > So what are you really trying do to?  If you're just trying to > visualize the results, I can work it out for you.  If it's something > more than that, then we'd need to talk about the details. > > Also note:  folding *one* 2D object is more or less straightforward.  > But folding it *again* is much less straightforward, as the big cubes > for subsequent folds start intersecting with unintended parts of the > model. >
BC
Bob Carlson
Tue, Nov 25, 2025 9:54 PM

On Nov 25, 2025, at 11:38, Jordan Brown via Discuss discuss@lists.openscad.org wrote:

However, before I figure out the answer... if you truly mean a 2D object, you're getting into a weird area:  2D objects that are not on the Z=0 plane.  OpenSCAD will do such operations, and will display something sensible, but after that there isn't much that you can do with them.  As 2D objects, you can only export them to 2D formats, which won't be all that useful no matter what it does.  (And I think what it will do is project back down to Z=0.)

I politely disagree. I will occasionally design a 2D shape as a point list, then extrude. If the end result is something other than a vertical extrusion, I find I waste a lot of time positioning the result the way I want it. BOSL2s orient and spin seem straight forward but are not intuitive, at least for me. I end up doing a lot of guess and check. So I came up with this library module. Most of the time I use it in the X=0 or Y=0 planes, but it works anywhere I believe.

include <BOSL2/std.scad>

module linear_extrude3d(path, h) {
d0 = assert(is_coplanar(path),
"Path Is Not Coplanar (from linear_extrude3d)");
r = polygon_normal(path);
c = centroid(path);

move([c.x, c.y, c.z])
rot(from = UP, to = r)
linear_extrude(h)
polygon(
    path2d(
        apply(rot(from=r, to=UP),
            apply(move([-c.x, -c.y, -c.z]), path)
        )
    )
);

}

path = [[0, 0, 0], [0, 3, 4], [0, 3, 0]];
linear_extrude3d(path, 10);

p0 = apply(move([4, -5, 2]), path);
linear_extrude3d(p0, 10);

p1 = apply(rot(from = RIGHT, to = UP + RIGHT + FRONT), p0);
linear_extrude3d(p1, 10);

On Nov 25, 2025, at 11:38, Jordan Brown via Discuss <discuss@lists.openscad.org> wrote: However, before I figure out the answer... if you truly mean a 2D object, you're getting into a weird area: 2D objects that are not on the Z=0 plane. OpenSCAD will do such operations, and will display something sensible, but after that there isn't much that you can do with them. As 2D objects, you can only export them to 2D formats, which won't be all that useful no matter what it does. (And I think what it will do is project back down to Z=0.) I politely disagree. I will occasionally design a 2D shape as a point list, then extrude. If the end result is something other than a vertical extrusion, I find I waste a lot of time positioning the result the way I want it. BOSL2s orient and spin seem straight forward but are not intuitive, at least for me. I end up doing a lot of guess and check. So I came up with this library module. Most of the time I use it in the X=0 or Y=0 planes, but it works anywhere I believe. include <BOSL2/std.scad> module linear_extrude3d(path, h) { d0 = assert(is_coplanar(path), "Path Is Not Coplanar (from linear_extrude3d)"); r = polygon_normal(path); c = centroid(path); move([c.x, c.y, c.z]) rot(from = UP, to = r) linear_extrude(h) polygon( path2d( apply(rot(from=r, to=UP), apply(move([-c.x, -c.y, -c.z]), path) ) ) ); } path = [[0, 0, 0], [0, 3, 4], [0, 3, 0]]; linear_extrude3d(path, 10); p0 = apply(move([4, -5, 2]), path); linear_extrude3d(p0, 10); p1 = apply(rot(from = RIGHT, to = UP + RIGHT + FRONT), p0); linear_extrude3d(p1, 10);
AM
Adrian Mariano
Tue, Nov 25, 2025 10:06 PM

Note that you can tidy your code a bit (at least I think it's tidier) by
writing apply(rot(from=r, to=UP)*move(-c), path) for example.  You also
don't have to use apply as all the transformations can also directly
operate on a path.  Setting orient is basically the same as rot(from=UP,
to=orient_direction).  But spin gets wonky because Revar made it spin
around the anchor point, not the object center.  This seems wrong to me.

Also I don't think Jordan was saying that 2d objects in 3 dimensions are
fundamentally useless.  Rather he meant specifically that OpenSCAD 2d
geometry is not useful if it's not on the XY plane.  You used a point list
to work around this limitation.

On Tue, Nov 25, 2025 at 4:55 PM Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

On Nov 25, 2025, at 11:38, Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

However, before I figure out the answer... if you truly mean a 2D object,
you're getting into a weird area:  2D objects that are not on the Z=0
plane.  OpenSCAD will do such operations, and will display something
sensible, but after that there isn't much that you can do with them.  As 2D
objects, you can only export them to 2D formats, which won't be all that
useful no matter what it does
.  (And I think what it will do is project
back down to Z=0.)

I politely disagree. I will occasionally design a 2D shape as a point
list, then extrude. If the end result is something other than a vertical
extrusion, I find I waste a lot of time positioning the result the way I
want it. BOSL2s orient and spin seem straight forward but are not
intuitive, at least for me. I end up doing a lot of guess and check. So I
came up with this library module. Most of the time I use it in the X=0 or
Y=0 planes, but it works anywhere I believe.

include <BOSL2/std.scad>

module linear_extrude3d(path, h) {
d0 = assert(is_coplanar(path),
"Path Is Not Coplanar (from linear_extrude3d)");
r = polygon_normal(path);
c = centroid(path);

move([c.x, c.y, c.z])
rot(from = UP, to = r)
linear_extrude(h)
polygon(
path2d(
apply(rot(from=r, to=UP),
apply(move([-c.x, -c.y, -c.z]), path)
)
)
);
}

path = [[0, 0, 0], [0, 3, 4], [0, 3, 0]];
linear_extrude3d(path, 10);

p0 = apply(move([4, -5, 2]), path);
linear_extrude3d(p0, 10);

p1 = apply(rot(from = RIGHT, to = UP + RIGHT + FRONT), p0);
linear_extrude3d(p1, 10);


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

Note that you can tidy your code a bit (at least I think it's tidier) by writing apply(rot(from=r, to=UP)*move(-c), path) for example. You also don't have to use apply as all the transformations can also directly operate on a path. Setting orient is basically the same as rot(from=UP, to=orient_direction). But spin gets wonky because Revar made it spin around the anchor point, not the object center. This seems wrong to me. Also I don't think Jordan was saying that 2d objects in 3 dimensions are fundamentally useless. Rather he meant specifically that OpenSCAD 2d geometry is not useful if it's not on the XY plane. You used a point list to work around this limitation. On Tue, Nov 25, 2025 at 4:55 PM Bob Carlson via Discuss < discuss@lists.openscad.org> wrote: > > On Nov 25, 2025, at 11:38, Jordan Brown via Discuss < > discuss@lists.openscad.org> wrote: > > However, before I figure out the answer... if you truly mean a 2D object, > you're getting into a weird area: 2D objects that are not on the Z=0 > plane. OpenSCAD will do such operations, and will display something > sensible, but after that there isn't much that you can do with them. As 2D > objects, you can only export them to 2D formats, which *won't be all that > useful no matter what it does*. (And I think what it will do is project > back down to Z=0.) > > > I politely disagree. I will occasionally design a 2D shape as a point > list, then extrude. If the end result is something other than a vertical > extrusion, I find I waste a lot of time positioning the result the way I > want it. BOSL2s orient and spin seem straight forward but are not > intuitive, at least for me. I end up doing a lot of guess and check. So I > came up with this library module. Most of the time I use it in the X=0 or > Y=0 planes, but it works anywhere I believe. > > include <BOSL2/std.scad> > > module linear_extrude3d(path, h) { > d0 = assert(is_coplanar(path), > "Path Is Not Coplanar (from linear_extrude3d)"); > r = polygon_normal(path); > c = centroid(path); > > move([c.x, c.y, c.z]) > rot(from = UP, to = r) > linear_extrude(h) > polygon( > path2d( > apply(rot(from=r, to=UP), > apply(move([-c.x, -c.y, -c.z]), path) > ) > ) > ); > } > > path = [[0, 0, 0], [0, 3, 4], [0, 3, 0]]; > linear_extrude3d(path, 10); > > p0 = apply(move([4, -5, 2]), path); > linear_extrude3d(p0, 10); > > p1 = apply(rot(from = RIGHT, to = UP + RIGHT + FRONT), p0); > linear_extrude3d(p1, 10); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Tue, Nov 25, 2025 10:21 PM

On 11/25/2025 2:06 PM, Adrian Mariano via Discuss wrote:

Also I don't think Jordan was saying that 2d objects in 3 dimensions
are fundamentally useless.  Rather he meant specifically that OpenSCAD
2d geometry is not useful if it's not on the XY plane.

Yes.

And note that that particular "won't be all that useful" comment was
with respect to exporting a non-XY-plane 2D object to a 2D format. 
Doubly so as here) when we were potentially talking about multiple 2D
objects on different planes.

rotate([0,30,0]) translate([-10,0,0]) square(10);
rotate([0,-30,0]) square(10);

It's hard to see how exporting that to a 2D format (other than, as here,
an image) would be useful.  (OK, very limited cases like making plan and
elevation views.)

On 11/25/2025 2:06 PM, Adrian Mariano via Discuss wrote: > Also I don't think Jordan was saying that 2d objects in 3 dimensions > are fundamentally useless.  Rather he meant specifically that OpenSCAD > 2d geometry is not useful if it's not on the XY plane. Yes. And note that that particular "won't be all that useful" comment was with respect to exporting a non-XY-plane 2D object to a 2D format.  Doubly so as here) when we were potentially talking about multiple 2D objects on different planes. rotate([0,30,0]) translate([-10,0,0]) square(10); rotate([0,-30,0]) square(10); It's hard to see how exporting that to a 2D format (other than, as here, an image) would be useful.  (OK, very limited cases like making plan and elevation views.)