discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

What is wrong with this for loop?

I
infocean
Wed, Mar 24, 2021 4:48 AM

Hi,

I am sure I do not understand something essential about the for loop in
OpenSCAD.  Here is my little code:

//Parameters for the cool air ducts
cadductsn = 4;  //Number of cool air ducts
caddiamo = 3;  //Outer diameter of cool air ducts
caddiami = 2;  //Inner diameter of cool air ducts
cadlength = 40;  //Length of cool air ducts
caddist = 12.5;  //distance of cool air ducts from x-axis
pcoolairducts = 27.5;

// Module onecoolairduct
module onecoolairduct(){
rotate([0,90,0])
translate([caddist,0,0])
linear_extrude(cadlength,center=true,convexity=10)
difference(){
circle(r=caddiamo/2);
circle(r=caddiami/2);
}
}

// Module coolairduct
module coolairduct(){
for(i=[1:cadductsn])
rotate([360/cadductsn,0,0])
onecoolairduct();
}

My expectation was that I will get four of these pipes with 90 degree
rotation to each other.  I see only one.  What am I doing wrong?

Thanks ahead,
Infocean

--
Sent from: http://forum.openscad.org/

Hi, I am sure I do not understand something essential about the for loop in OpenSCAD. Here is my little code: //Parameters for the cool air ducts cadductsn = 4; //Number of cool air ducts caddiamo = 3; //Outer diameter of cool air ducts caddiami = 2; //Inner diameter of cool air ducts cadlength = 40; //Length of cool air ducts caddist = 12.5; //distance of cool air ducts from x-axis pcoolairducts = 27.5; // Module onecoolairduct module onecoolairduct(){ rotate([0,90,0]) translate([caddist,0,0]) linear_extrude(cadlength,center=true,convexity=10) difference(){ circle(r=caddiamo/2); circle(r=caddiami/2); } } // Module coolairduct module coolairduct(){ for(i=[1:cadductsn]) rotate([360/cadductsn,0,0]) onecoolairduct(); } My expectation was that I will get four of these pipes with 90 degree rotation to each other. I see only one. What am I doing wrong? Thanks ahead, Infocean -- Sent from: http://forum.openscad.org/
TP
Torsten Paul
Wed, Mar 24, 2021 4:56 AM

On 24.03.21 05:48, infocean via Discuss wrote:

rotate([360/cadductsn,0,0])

I suspect that should read: rotate([90*i,0,0])

ciao,
Torsten.

On 24.03.21 05:48, infocean via Discuss wrote: > rotate([360/cadductsn,0,0]) I suspect that should read: rotate([90*i,0,0]) ciao, Torsten.
I
infocean
Wed, Mar 24, 2021 5:03 AM

Yes, you are right .
rotate([i*360/cadductsn,0,0])

Thanks for looking at it!

--
Sent from: http://forum.openscad.org/

Yes, you are right . rotate([i*360/cadductsn,0,0]) Thanks for looking at it! -- Sent from: http://forum.openscad.org/