Hi all,
Being new to openScad I'm exploring its methods with a view to replacing
another CAD program I have.
I have wriiten this:-
$fn = 50;
module RadialCopy( numCopies, radius)
{
dtr = PI/180;
angStep = 360/numCopies;
for(i=[0:angStep:360])
{
x = radiuscos(i);
y = radiussin(i);
translate([x,y,0])cylinder(5,1,true);
}
}
// Call the RadialCopy module
RadialCopy( 6, 10);
which copies a cylinder <numCopies> times around a centre point.
but what if I wanted to copy another object like a sphere or a cube ? I
would have to change the RadialCopy module each time, instead I want to
keep the generality of the module, and pass the object I want to copy as
a parameter.
Can I do this ? I've read a bit about using children but didn't really
understand it or get it to work the way I wanted.
Any advice appreciated.
thanks,
Steve.
$fn = 50;
module RadialCopy( numCopies, radius)
{
dtr = PI/180;
angStep = 360/numCopies;
for(i=[0:angStep:360])
{
x = radius*cos(i);
y = radius*sin(i);
translate([x,y,0]) children();
}
}
// Call the RadialCopy module
RadialCopy( 6, 10)
cylinder(5,1,true);
RadialCopy( 6, 15)
cube(1);
Admin - email* me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
--
Sent from: http://forum.openscad.org/