discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Loops inside intersection()

JB
Jon Bondy
Sat, Dec 27, 2025 9:00 PM

I expected the two shapes to be the same (the red shape, not the green)

$fn = 90;
ct = 18;

posn = [
    [50, 0, 0],
    [-50, 0, 0]
    ];

color("red")
    intersection() {
        translate([50, 0, 0])
            cylinder(h = ct, d = 200);
        translate([-50, 0, 0])
            cylinder(h = ct, d = 200);
        }

color("green")
    intersection() {
        for (i = [0:1])
            translate(posn[i])
                cylinder(h = ct/2, d = 200);
        }

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

I expected the two shapes to be the same (the red shape, not the green) $fn = 90; ct = 18; posn = [     [50, 0, 0],     [-50, 0, 0]     ]; color("red")     intersection() {         translate([50, 0, 0])             cylinder(h = ct, d = 200);         translate([-50, 0, 0])             cylinder(h = ct, d = 200);         } color("green")     intersection() {         for (i = [0:1])             translate(posn[i])                 cylinder(h = ct/2, d = 200);         } -- This email has been checked for viruses by AVG antivirus software. www.avg.com
LD
lee.deraud@roadrunner.com
Sat, Dec 27, 2025 9:16 PM

Haven't actually looked at the output, but at first glance I would expect:
(1) the 'red example to be the intersection of two translated cylinders, and
(2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing.

Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd
sort of expect a null object as the result. Does that "lazy union" setting come into play here?

(Or just ignore me, it's been a low-caffeine day.)

-----Original Message-----
From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Saturday, December 27, 2025 1:00 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] Loops inside intersection()

I expected the two shapes to be the same (the red shape, not the green)

$fn = 90;
ct = 18;

posn = [
[50, 0, 0],
[-50, 0, 0]
];

color("red")
intersection() {
translate([50, 0, 0])
cylinder(h = ct, d = 200);
translate([-50, 0, 0])
cylinder(h = ct, d = 200);
}

color("green")
intersection() {
for (i = [0:1])
translate(posn[i])
cylinder(h = ct/2, d = 200);
}

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

Haven't actually looked at the output, but at first glance I would expect: (1) the 'red example to be the intersection of two translated cylinders, and (2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing. Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd sort of expect a null object as the result. Does that "lazy union" setting come into play here? (Or just ignore me, it's been a low-caffeine day.) -----Original Message----- From: Jon Bondy via Discuss <discuss@lists.openscad.org> Sent: Saturday, December 27, 2025 1:00 PM To: OpenSCAD general discussion <discuss@lists.openscad.org> Cc: Jon Bondy <jon@jonbondy.com> Subject: [OpenSCAD] Loops inside intersection() I expected the two shapes to be the same (the red shape, not the green) $fn = 90; ct = 18; posn = [ [50, 0, 0], [-50, 0, 0] ]; color("red") intersection() { translate([50, 0, 0]) cylinder(h = ct, d = 200); translate([-50, 0, 0]) cylinder(h = ct, d = 200); } color("green") intersection() { for (i = [0:1]) translate(posn[i]) cylinder(h = ct/2, d = 200); } -- 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
Jon Bondy
Sat, Dec 27, 2025 9:23 PM

Ah.  Implicit union.

Perhaps.

Let's let others chime in.

On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote:

Haven't actually looked at the output, but at first glance I would expect:
(1) the 'red example to be the intersection of two translated cylinders, and
(2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing.

Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd
sort of expect a null object as the result. Does that "lazy union" setting come into play here?

(Or just ignore me, it's been a low-caffeine day.)

-----Original Message-----
From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Saturday, December 27, 2025 1:00 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] Loops inside intersection()

I expected the two shapes to be the same (the red shape, not the green)

$fn = 90;
ct = 18;

posn = [
[50, 0, 0],
[-50, 0, 0]
];

color("red")
intersection() {
translate([50, 0, 0])
cylinder(h = ct, d = 200);
translate([-50, 0, 0])
cylinder(h = ct, d = 200);
}

color("green")
intersection() {
for (i = [0:1])
translate(posn[i])
cylinder(h = ct/2, d = 200);
}

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

Ah.  Implicit union. Perhaps. Let's let others chime in. On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote: > Haven't actually looked at the output, but at first glance I would expect: > (1) the 'red example to be the intersection of two translated cylinders, and > (2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing. > > Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd > sort of expect a null object as the result. Does that "lazy union" setting come into play here? > > (Or just ignore me, it's been a low-caffeine day.) > > -----Original Message----- > From: Jon Bondy via Discuss <discuss@lists.openscad.org> > Sent: Saturday, December 27, 2025 1:00 PM > To: OpenSCAD general discussion <discuss@lists.openscad.org> > Cc: Jon Bondy <jon@jonbondy.com> > Subject: [OpenSCAD] Loops inside intersection() > > I expected the two shapes to be the same (the red shape, not the green) > > > $fn = 90; > ct = 18; > > posn = [ > [50, 0, 0], > [-50, 0, 0] > ]; > > color("red") > intersection() { > translate([50, 0, 0]) > cylinder(h = ct, d = 200); > translate([-50, 0, 0]) > cylinder(h = ct, d = 200); > } > > color("green") > intersection() { > for (i = [0:1]) > translate(posn[i]) > cylinder(h = ct/2, d = 200); > } > > -- This email has been checked for viruses by AVG antivirus software. www.avg.com
NH
nop head
Sat, Dec 27, 2025 9:47 PM

Use intersection_for instead of for

On Sat, 27 Dec 2025, 21:23 Jon Bondy via Discuss, <
discuss@lists.openscad.org> wrote:

Ah.  Implicit union.

Perhaps.

Let's let others chime in.

On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote:

Haven't actually looked at the output, but at first glance I would

expect:

(1) the 'red example to be the intersection of two translated cylinders,

and

(2) the 'green' example to be an implicit union of the two translated

cylinders, intersected with...nothing.

Having said that, I have absolutely no idea how OS handles an

intersection with a null object, but I'd

sort of expect a null object as the result. Does that "lazy union"

setting come into play here?

(Or just ignore me, it's been a low-caffeine day.)

-----Original Message-----
From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Saturday, December 27, 2025 1:00 PM
To: OpenSCAD general discussion discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] Loops inside intersection()

I expected the two shapes to be the same (the red shape, not the green)

$fn = 90;
ct = 18;

posn = [
[50, 0, 0],
[-50, 0, 0]
];

color("red")
intersection() {
translate([50, 0, 0])
cylinder(h = ct, d = 200);
translate([-50, 0, 0])
cylinder(h = ct, d = 200);
}

color("green")
intersection() {
for (i = [0:1])
translate(posn[i])
cylinder(h = ct/2, d = 200);
}

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

Use intersection_for instead of for On Sat, 27 Dec 2025, 21:23 Jon Bondy via Discuss, < discuss@lists.openscad.org> wrote: > Ah. Implicit union. > > Perhaps. > > Let's let others chime in. > > > On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote: > > Haven't actually looked at the output, but at first glance I would > expect: > > (1) the 'red example to be the intersection of two translated cylinders, > and > > (2) the 'green' example to be an implicit union of the two translated > cylinders, intersected with...nothing. > > > > Having said that, I have absolutely no idea how OS handles an > intersection with a null object, but I'd > > sort of expect a null object as the result. Does that "lazy union" > setting come into play here? > > > > (Or just ignore me, it's been a low-caffeine day.) > > > > -----Original Message----- > > From: Jon Bondy via Discuss <discuss@lists.openscad.org> > > Sent: Saturday, December 27, 2025 1:00 PM > > To: OpenSCAD general discussion <discuss@lists.openscad.org> > > Cc: Jon Bondy <jon@jonbondy.com> > > Subject: [OpenSCAD] Loops inside intersection() > > > > I expected the two shapes to be the same (the red shape, not the green) > > > > > > $fn = 90; > > ct = 18; > > > > posn = [ > > [50, 0, 0], > > [-50, 0, 0] > > ]; > > > > color("red") > > intersection() { > > translate([50, 0, 0]) > > cylinder(h = ct, d = 200); > > translate([-50, 0, 0]) > > cylinder(h = ct, d = 200); > > } > > > > color("green") > > intersection() { > > for (i = [0:1]) > > translate(posn[i]) > > cylinder(h = ct/2, d = 200); > > } > > > > > > -- > 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
JJ
jon jonbondy.com
Sat, Dec 27, 2025 10:14 PM

Ah.  Thanks.  Shows how often I use intersection()!!!

On 12/27/2025 4:47 PM, nop head wrote:
Use intersection_for instead of for

On Sat, 27 Dec 2025, 21:23 Jon Bondy via Discuss, <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org> wrote:
Ah.  Implicit union.

Perhaps.

Let's let others chime in.

On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote:

Haven't actually looked at the output, but at first glance I would expect:
(1) the 'red example to be the intersection of two translated cylinders, and
(2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing.

Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd
sort of expect a null object as the result. Does that "lazy union" setting come into play here?

(Or just ignore me, it's been a low-caffeine day.)

-----Original Message-----
From: Jon Bondy via Discuss <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org>
Sent: Saturday, December 27, 2025 1:00 PM
To: OpenSCAD general discussion <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org>
Cc: Jon Bondy <jon@jonbondy.commailto:jon@jonbondy.com>
Subject: [OpenSCAD] Loops inside intersection()

I expected the two shapes to be the same (the red shape, not the green)

$fn = 90;
ct = 18;

posn = [
[50, 0, 0],
[-50, 0, 0]
];

color("red")
intersection() {
translate([50, 0, 0])
cylinder(h = ct, d = 200);
translate([-50, 0, 0])
cylinder(h = ct, d = 200);
}

color("green")
intersection() {
for (i = [0:1])
translate(posn[i])
cylinder(h = ct/2, d = 200);
}

Ah. Thanks. Shows how often I use intersection()!!! On 12/27/2025 4:47 PM, nop head wrote: Use intersection_for instead of for On Sat, 27 Dec 2025, 21:23 Jon Bondy via Discuss, <discuss@lists.openscad.org<mailto:discuss@lists.openscad.org>> wrote: Ah. Implicit union. Perhaps. Let's let others chime in. On 12/27/2025 4:16 PM, Lee DeRaud via Discuss wrote: > Haven't actually looked at the output, but at first glance I would expect: > (1) the 'red example to be the intersection of two translated cylinders, and > (2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing. > > Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd > sort of expect a null object as the result. Does that "lazy union" setting come into play here? > > (Or just ignore me, it's been a low-caffeine day.) > > -----Original Message----- > From: Jon Bondy via Discuss <discuss@lists.openscad.org<mailto:discuss@lists.openscad.org>> > Sent: Saturday, December 27, 2025 1:00 PM > To: OpenSCAD general discussion <discuss@lists.openscad.org<mailto:discuss@lists.openscad.org>> > Cc: Jon Bondy <jon@jonbondy.com<mailto:jon@jonbondy.com>> > Subject: [OpenSCAD] Loops inside intersection() > > I expected the two shapes to be the same (the red shape, not the green) > > > $fn = 90; > ct = 18; > > posn = [ > [50, 0, 0], > [-50, 0, 0] > ]; > > color("red") > intersection() { > translate([50, 0, 0]) > cylinder(h = ct, d = 200); > translate([-50, 0, 0]) > cylinder(h = ct, d = 200); > } > > color("green") > intersection() { > for (i = [0:1]) > translate(posn[i]) > cylinder(h = ct/2, d = 200); > } > > -- 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=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=7HuqWkntY80kKdDwlV8iEKcPLFqQltxgzyquJgkxck26PKEQz5elZ-6a53FPj-4l&s=C_gQaorxgnbzsW3m22GiOM4DefMt5Ul9Ho3jcbwsOqY&e=> _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org<mailto:discuss-leave@lists.openscad.org>
JB
Jordan Brown
Sun, Dec 28, 2025 4:32 AM

On 12/27/2025 1:16 PM, Lee DeRaud via Discuss wrote:

Haven't actually looked at the output, but at first glance I would expect:
(1) the 'red example to be the intersection of two translated cylinders, and
(2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing.

Correct, mostly.  for(), like most modules, implicitly unions its
children and, like all modules, implicitly unions all of the shapes that
it produces.

Repeat after me:  a module invocation always yields exactly one shape. 
(Exception:  There are a very few that yield zero shapes.)

Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd
sort of expect a null object as the result. Does that "lazy union" setting come into play here?

There is no spoon. https://www.youtube.com/watch?v=XO0pcWxcROI  Or,
rather, there is no null object in this picture.

Once we get to the intersection, it's equivalent to:

intersection() {
    cube();
}

Intersection is defined to yield the volume that is in common between
all of its children.  "all" is well-defined for a single child.  For a
single child C, like the cube above, and like the for() in the original
question, the shape that is in common between all of its children is... C.

Intersection with no children gets ... philosophical.  There's a decent
argument that it should yield the entire universe, since when you then
intersect that with the first child, you get that first child.  But in
practice it yields an empty object.

On 12/27/2025 1:16 PM, Lee DeRaud via Discuss wrote: > Haven't actually looked at the output, but at first glance I would expect: > (1) the 'red example to be the intersection of two translated cylinders, and > (2) the 'green' example to be an implicit union of the two translated cylinders, intersected with...nothing. Correct, mostly.  for(), like most modules, implicitly unions its children and, like all modules, implicitly unions all of the shapes that it produces. Repeat after me:  a module invocation always yields exactly one shape.  (Exception:  There are a very few that yield zero shapes.) > Having said that, I have absolutely no idea how OS handles an intersection with a null object, but I'd > sort of expect a null object as the result. Does that "lazy union" setting come into play here? There is no spoon. <https://www.youtube.com/watch?v=XO0pcWxcROI>  Or, rather, there is no null object in this picture. Once we get to the intersection, it's equivalent to: intersection() { cube(); } Intersection is defined to yield the volume that is in common between all of its children.  "all" is well-defined for a single child.  For a single child C, like the cube above, and like the for() in the original question, the shape that is in common between all of its children is... C. Intersection with no children gets ... philosophical.  There's a decent argument that it should yield the entire universe, since when you then intersect that with the first child, you get that first child.  But in practice it yields an empty object.
MM
Michael Marx (spintel)
Sun, Dec 28, 2025 5:13 AM

There is no https://www.youtube.com/watch?v=XO0pcWxcROI  spoon.

Getting meta, no video of no spoon "Video unavailable The uploader has not made this video available in your country" :-)


From: Jordan Brown via Discuss [mailto:discuss@lists.openscad.org]

There is no <https://www.youtube.com/watch?v=XO0pcWxcROI> spoon. Getting meta, no video of no spoon "Video unavailable The uploader has not made this video available in your country" :-) _____ From: Jordan Brown via Discuss [mailto:discuss@lists.openscad.org]