// allviews bloc bloc_metric anneau // viewopts bloc brim5mm // testviews test1 test1_metric test2 test2_metric nut_hole // testviews assemblage test_anneau test_bloc test_anneau,test_bloc:h30 // printviews bloc:x2,w70 anneau:x2,y2,w70,h70 bloc,anneau:w70,h70 // viewopts bloc:x2,w70 brim5mm include use <../cadlib.h> ray=30; height=27; nutw_3_4=20+0.5; nutw_metric=19.5+0.7; pin_hole=2.5; module nut_hole(nutw){ nut(nutw,14,false); translate([0,0,14]) intersection(){ nut(nutw,20,false); sphere(r=12,$fn=80); } } module pins(pinray,pinheight,cone){ p2=pinray/2; for (x=[0:5]){ rotate([0,0,x*360/6]) translate([ray-5,0,0]){ translate([-p2,-pinray,0]) cube([pinray,pinray*2,pinheight]); if (cone){ sphere(r=pinray+0.5,$fn=40); } } } } module bloc(nutw,is_metric){ difference(){ intersection(){ translate([0,0,0]) sphere(r=ray,$fn=80); r2=ray*2; translate([-r2,-r2,0]) cube([r2*2,r2*2,height]); } union(){ translate([0,0,-1]) nut_hole(nutw); if (is_metric){ translate([-4,-3,height-1]) linear_extrude(3) text("M",size=7); } translate([0,0,-1]) pins(pin_hole+1.5,8,true); } } for (x=[0:5]){ rotate([0,0,x*360/6]){ thick=0.7; translate([nutw/2,0,3]) rotate([0,90,90]) triangle_rectangle(3,thick,1); translate([nutw/2-thick,0,3]) cube([thick,1,9]); } } } module anneau(){ thick=2.5; difference(){ cylinder(r=ray,h=thick,$fn=80); translate([0,0,-1]) cylinder(r=ray-7,h=5,$fn=80); } translate([0,0,thick]) pins(pin_hole,4,false); } module test(hei,nutw){ intersection(){ cylinder(r=15,h=hei,$fn=80); translate([0,0,0]) bloc(nutw,false); } } module main_view(view){ if (view=="bloc"){ bloc(nutw_3_4,false); }else if (view=="bloc_metric"){ bloc(nutw_metric,true); }else if (view=="test1"){ test(1,nutw_3_4); }else if (view=="test1_metric"){ test(1,nutw_metric); }else if (view=="test2"){ test(12,nutw_3_4); }else if (view=="test2_metric"){ test(12,nutw_metric); }else if (view=="nut_hole"){ nut_hole(nutw_3_4); }else if (view=="anneau"){ anneau(); }else if (view=="test_anneau"){ intersection(){ translate([-20,15,0]) cube([40,20,10]); anneau(); } }else if (view=="test_bloc"){ intersection(){ translate([-20,17,0]) cube([40,20,8]); bloc(nutw_3_4,false); } }else if (view=="assemblage"){ anneau(); translate([0,0,6]) bloc(nutw_3_4,false); } }