discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

going loopy

BR
Bob Roos
Sun, Jun 21, 2026 11:07 PM

Hello Discuss,

Thank you everyone for the clarification and help with aligh, position and attach

I am not understanding why K is looping 15 times and not just 4.  I get the result I wanted, but I think I am going over things 3 times.

include <BOSL2/std.scad> //or screws or threading
$fn=24;
Inch=25.4;
LHF = .28;      // Layer height for faster build
LH=.25; // Layer height after 1st layer
FL=.2; // first layer

D = 100;
L = 190;
T = 2;
H = 20;
VertShift = 15;
List=[[-2,8,1.5],[-1,9,1],[0,11,.3],[1,9,1],[2,8,1.5]];

diff(){
cuboid([L-D,D,T],anchor=TOP);
right((L-D)/2)cyl(h=T,d=D,anchor=TOP);
left((L-D)/2)cyl(h=T,d=D,anchor=TOP);
for (k=[0:1:len(List)-1]){
shift = List[k][2];
columns= List[k][1];
offset = List[k][0];
echo(columns,offset,len(List),k);
right(shift20)for (i=[0:1:columns]){tag("remove")#left((L-D)-15i)back(offsetVertShift)cube([6,6,T2],anchor=CENTER);}
}
}

Best regards,
Bob                          mailto:roosbob@wybatap.com

Hello Discuss, Thank you everyone for the clarification and help with aligh, position and attach I am not understanding why K is looping 15 times and not just 4. I get the result I wanted, but I think I am going over things 3 times. include <BOSL2/std.scad> //or screws or threading $fn=24; Inch=25.4; LHF = .28; // Layer height for faster build LH=.25; // Layer height after 1st layer FL=.2; // first layer D = 100; L = 190; T = 2; H = 20; VertShift = 15; List=[[-2,8,1.5],[-1,9,1],[0,11,.3],[1,9,1],[2,8,1.5]]; diff(){ cuboid([L-D,D,T],anchor=TOP); right((L-D)/2)cyl(h=T,d=D,anchor=TOP); left((L-D)/2)cyl(h=T,d=D,anchor=TOP); for (k=[0:1:len(List)-1]){ shift = List[k][2]; columns= List[k][1]; offset = List[k][0]; echo(columns,offset,len(List),k); right(shift*20)for (i=[0:1:columns]){tag("remove")#left((L-D)-15*i)back(offset*VertShift)cube([6,6,T*2],anchor=CENTER);} } } -- Best regards, Bob mailto:roosbob@wybatap.com
JB
Jordan Brown
Mon, Jun 22, 2026 12:11 AM

I am not understanding why K is looping 15 times and not just 4.  I get the result I wanted, but I think I am going over things 3 times.

BOSL2’s diff() evaluates its children three times.

https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff

Third paragraph under Description.

> I am not understanding why K is looping 15 times and not just 4. I get the result I wanted, but I think I am going over things 3 times. BOSL2’s diff() evaluates its children three times. https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff Third paragraph under Description.
BR
Bob Roos
Mon, Jun 22, 2026 12:45 AM

Hi Jordan,

Twas blind but now I see.  Thank you

Sunday, June 21, 2026, 8:11:00 PM, you wrote:

I am not understanding why K is looping 15 times and not just 4.  I get the result I wanted, but I think I am going over things 3 times.

BOSL2’s diff() evaluates its children three times.

Third paragraph under Description.

--
have Fun,
Bob                          mailto:roosbob@wybatap.com

Hi Jordan, Twas blind but now I see. Thank you Sunday, June 21, 2026, 8:11:00 PM, you wrote: >> I am not understanding why K is looping 15 times and not just 4. I get the result I wanted, but I think I am going over things 3 times. > BOSL2’s diff() evaluates its children three times. > https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff > Third paragraph under Description. -- have Fun, Bob mailto:roosbob@wybatap.com
AM
Adrian Mariano
Mon, Jun 22, 2026 12:56 AM

I don't see any child objects in that diff(), which means you could change
out diff() for difference() and avoid the triple execution weirdness.
Where you really need diff is when you're using align or attach to place
the differenced object.

On Sun, Jun 21, 2026 at 8:46 PM Bob Roos via Discuss <
discuss@lists.openscad.org> wrote:

Hi Jordan,

Twas blind but now I see.  Thank you

Sunday, June 21, 2026, 8:11:00 PM, you wrote:

I am not understanding why K is looping 15 times and not just 4.  I get

the result I wanted, but I think I am going over things 3 times.

BOSL2’s diff() evaluates its children three times.

Third paragraph under Description.

--
have Fun,
Bob                          mailto:roosbob@wybatap.com


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

I don't see any child objects in that diff(), which means you could change out diff() for difference() and avoid the triple execution weirdness. Where you really need diff is when you're using align or attach to place the differenced object. On Sun, Jun 21, 2026 at 8:46 PM Bob Roos via Discuss < discuss@lists.openscad.org> wrote: > Hi Jordan, > > Twas blind but now I see. Thank you > > Sunday, June 21, 2026, 8:11:00 PM, you wrote: > > >> I am not understanding why K is looping 15 times and not just 4. I get > the result I wanted, but I think I am going over things 3 times. > > > BOSL2’s diff() evaluates its children three times. > > > https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff > > > Third paragraph under Description. > > > -- > have Fun, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org