include // For the text $fa = 2; $fs = 1; sides = [ 150, 100, 50, 25 ]; layerT = 6; // Thickness of each layer d = 50; // Diameter textT = 0.4; // Thickness of text on the side topTextT = 0.6; // Thickness of text on the top font = "Liberation Sans:style=Bold"; arcW = 20; // Width of arc, if in arc mode h = layerT * len(sides); // Draw a label wrapped around the cylinder module clabel(text) { path = up(layerT/2, path3d(reverse(circle(d=d)))); path_text(path, text, size=layerT*0.8, textmetrics=true, valign="center", font=font, h=textT*2+2, offset=-1, center=true); } if (d > 100) { a = asin(100/d)*2; difference() { for (i=[0:len(sides)-1]) translate([0,0,i*layerT]) { fn = sides[i]; zcyl(d=d, h=layerT, anchor=BOTTOM, $fn=fn); rotate(180) { rotate(0) clabel(str(fn)); if (d >= 25) { rotate(a/3) clabel(str(round(360/fn*10)/10, "°")); rotate(-a/3) clabel(str(round(PI*d/fn*10)/10, "mm")); } } } zcyl(d=d-arcW*2, h=h, extra=1, anchor=BOTTOM); rotate_extrude(a=360-a, start=a/2) translate([0,-1]) square([d/2+1, h+2]); } } else { for (i=[0:len(sides)-1]) translate([0,0,i*layerT]) { fn = sides[i]; zcyl(d=d, h=layerT, anchor=BOTTOM, $fn=fn); rotate(0) clabel(str(fn)); if (d >= 25) { rotate(120) clabel(str(round(360/fn*10)/10, "°")); rotate(-120) clabel(str(round(PI*d/fn*10)/10, "mm")); } } } if (d > 100) { topTextSize = arcW * 0.5; up(h) right(d/2 - arcW*0.6) { rotate(90) text3d(str(d, "mm"), atype="ycenter", anchor=BOTTOM, h=topTextT, size=topTextSize, font=font); } } else if (d >= 25) { topTextSize = d * 0.3; up(h) back(topTextSize*0.6) text3d(str(d), atype="ycenter", anchor=BOTTOM, h=topTextT, size=topTextSize, font=font); up(h) fwd(topTextSize*0.6) text3d("mm", atype="ycenter", anchor=BOTTOM, h=topTextT, size=topTextSize, font=font); } else { topTextSize = d * 0.5; up(h) text3d(str(d), atype="ycenter", anchor=BOTTOM, h=topTextT, size=topTextSize, font=font); }