main(); module main() { hullSeries(id=1,$fn=100) { tr([40,0,6],[0,90,0]) slice(14,8,4,9); tr([-40,0,7],[0,90+10,0]) slice(17,8,6,10); tr([-50,0,6],[0,90,0]) sphere(20); tr([-50,0,0],[90,0,0]) rcylinder(h=35,r1=20,r2=20,b=2); } } module t(v=[0,0,0]){translate(v) children();} module r(a=[0,0,0],rp=[0,0,0]){translate(rp) rotate(a) translate(-rp) children();} module tr(v=[0,0,0],a=[0,0,0],rp=[0,0,0]){t(v) r(a,rp) children();} module rcylinder(h=20,r1=10,r2=5,b=1) // ˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭ { translate([0,0,-h/2]) if (r1==r2) { rotate_extrude(convexity=1) { offset(r=b) offset(delta=-b) square([r1,h]); square([b,h]); } } else { cylinder(h,r1=b,r2=b,center=false); rotate_extrude() offset(b) offset(-b) projection() rotate([-90,0,0]) intersection() { cylinder(h,r1,r2,center=false); translate([0,-0.05,0]) cube([max(r1,r2)+1,0.1,h],false); } } } module hullSeries(id=1) // 0=objects, 1=stepwise,2=hull // ˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭˭ // id: 0=objects, 1=stepwise,2=hull { if (id==2) { hull() children(); } else if (id==1) { if ($children>1) for (i=[0:$children-2]) hull() { children(i); children(i+1); } else echo("--> Only one child <--"); } else if (id==0) { if ($children>0) for (i=[0:$children-1]) children(i); } else echo("HULLSERIES with wrong index id = ", id); } module slice(r1=14,r2=8,dx=4,dy=9) { linear_extrude(0.1) hull() { circle(r=r1); t([dx,0,0]) for (i=[-1,1]) t([0,i*dy]) circle(r=r2); } }