imagine I have a list of translations which I want to apply to the same object.
for instance, a list which defines rotation and translation
list = [[10,20],[30,45]]
how to I apply them in a for loop to one object?
I am looking for something like
for (i=list) {
translate([i[0],0,0])
rotate([i[1],0,0])
}
cube([10,1,1]);
obviously, that is the wrong approach...
any ideas?
This could be done by defining a module that steps through the list recursively.
list = [[10,20],[30,45]];
module transform(list, idx = 0) {
if (idx >= len(list)) {
children();
} else {
translate([list[idx][0],0,0])
rotate([list[idx][1],0,0])
transform(list, idx + 1)
children();
}
}
transform(list) cube([10,1,1]);