Cylinder_array (count, distance, rows)

3 messages
Open this post in threaded view
|

Cylinder_array (count, distance, rows)

 Hello everyone, im new to this forum and new to OpenSCAD program. Awsome program. First, i tried this: cylinder_array(21,5) cylinder(r=2, h=10); module cylinder_array( count, distance ){     for ( i = [0:1:count-1] ){         translate([distance*i,0,0])         children();     } } Then i wanted to copy that row into serveal rows. I didn't had a clue and i did like this: translate ([-0,0,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,5,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,10,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,15,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,20,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,25,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,30,0]) cylinder_array(21,5) cylinder(r=2, h=10); translate ([-0,35,0]) cylinder_array(21,5) cylinder(r=2, h=10); module cylinder_array( count, distance ){     for ( i = [0:1:count-1] ){         translate([distance*i,0,0])         children();     } } Cool i was thinking, but knew there a better way of doing this. If im gonna make serveal of these the code will be long and messy. Not good. Then i was thinking, hmm how? I tried this: cylinder_array(21,5,25) cylinder(r=2, h=10); module cylinder_array( count, distance, rows ){     for ( i = [0:1:count-1] ){         for ( h = [0:1:rows-1]){         translate([0,distance*i,0])             translate([rows+distance*h,0,0])         children();         }     } } Wow, i almost can taste it, much much less code but i dont think this is enterily correct either. I see the whole thing moved away from origin: 0,0 .. why? I know iv done something wrong here. Anyone out there can help me a little on the road?