What is wrong with this for loop?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What is wrong with this for loop?

OpenSCAD mailing list-2
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 the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
tp3
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong with this for loop?

tp3
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.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong with this for loop?

OpenSCAD mailing list-2
Yes, you are right .  
rotate([i*360/cadductsn,0,0])

Thanks for looking at it!

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]