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,distancei,0])
translate([rows+distanceh,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?
--
View this message in context: http://forum.openscad.org/Cylinder-array-count-distance-rows-tp21740.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
It is translated from the origin because you added rows to distance * h.
Here is a corrected version with even less code:
cylinder_array(21,5,25) cylinder(r=2, h=10);
module cylinder_array( count, distance, rows )
for (i = [0 : count - 1], h = [0 : rows-1])
translate([distance * h, distance * i, 0])
children();
On 25 June 2017 at 13:36, Droidene koford@gmail.com wrote:
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,distancei,0])
translate([rows+distanceh,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?
--
View this message in context: http://forum.openscad.org/
Cylinder-array-count-distance-rows-tp21740.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Ahh of course, thank you.
It make all sense, awsome.
--
View this message in context: http://forum.openscad.org/Cylinder-array-count-distance-rows-tp21740p21742.html
Sent from the OpenSCAD mailing list archive at Nabble.com.