use <../cadlib.h> // allviews holder base column_out column_in attach // testviews test_column_out test_column_in tests include // For the holder ray=37/2; thick=7; holer=8/2; handlelen=20+24; handlethick=21; threadr=15.75/2; threadlen=12*3; // For the desk support column_height=140; column_width=20; column_hole=20; pinr=2; base_height=40; module handle(){ difference(){ translate([-handlelen-ray,-thick/2,-ray]) cube([handlelen+ray,thick,ray*2]); translate([0,-thick,0]) rotate([-90,0,0]) cylinder(r=ray-1,h=handlethick+1); } translate([-handlelen-ray,-handlethick/2,-ray]) cube([handlelen,handlethick,ray*2]); } module circle0(){ translate([0,-thick/2,0]) rotate([-90,0,0]) difference(){ cylinder(r=ray,h=thick); cylinder(r=ray-1,h=thick); } translate([0,-thick/2+1,0]) rotate([-90,0,0]) cylinder(r=ray,h=thick-2); for (i=[0:1:6]){ rotate([0,180/6*i,0]) cube([ray*2,thick,0.5],center=true); } } module circle(){ difference(){ circle0(); translate([0,-10,0]) rotate([-90,0,0]) cylinder(r=holer,h=20,$fn=60); } } module support(){ difference(){ handle(); translate([-ray-handlelen+threadlen-1,0,0]) rotate ([0,-90,0]) cylinder(r=threadr,h=threadlen); } circle(); } module testthread(){ difference(){ w=2*threadr+3; cube([w,w,4],center=true); translate([0,0,-10]) cylinder(r=threadr,h=20); } } module attach(){ difference(){ difference(){ union(){ cylinder(r=threadr+3,h=column_hole,$fn=60); translate([3,-10/2,0]) cube([threadr*2-2,10,column_hole]); } union(){ cylinder(r=threadr+1,h=column_hole); translate([threadr*2-2.5,5,column_hole/2]) rotate([90,0,0]) cylinder(r=2,h=10); } } union(){ translate([3,-5/2,0]) cube([threadr*2,5,column_hole]); translate([17,0,0]) cube([threadr/2,5,column_hole]); } } } module column_in(width,height){ w=width-0.5; difference(){ rotate([-90,0,0]) cylinder(r=w/2,h=height,$fn=50); union(){ rotate([-90,0,0]) translate([0,0,4]) cylinder(r=width/2-2,h=height); if (height-40 > 15){ for (i=[1:(height-40)/15]){ translate([0,15*i,-width/2]) cylinder(r=pinr+0.25,h=width); } } } } difference(){ translate([-3/2,0,-width/2+0.25]) rotate([0,-90,180]) linear_extrude(3) polygon([[0,0],[0,8],[4,12], [w-4,12],[w,8],[w,0], [0,0]]); translate([-3,-8,0]) rotate([0,90,0]) cylinder(r=2,h=6); } } function getprofile(width)=[[-width/2,0],[-width/2,width/4],[-width/4,width/2], [width/4,width/2],[width/2,width/4],[width/2,-width/4], [width/4,-width/2],[-width/4,-width/2], [-width/2,-width/4],[-width/2,0]]; module column_out(width,height){ difference(){ profile(getprofile(width),height,6,0,3); union(){ rotate([-90,0,0]) cylinder(r=column_hole/2,h=column_height,$fn=50); // Small notch on the top translate([column_hole/2-2,-3,-4]) cube([3,6,8]); } } down=-width/2-3; translate([-10,-10,down]) cube([20,20,0.5]); translate([-10,height-10,down]) cube([20,20,0.5]); } module pin(){ translate([0,0,-5]){ cylinder(r=pinr,h=column_width+16); translate([0,0,7]) cylinder(r=pinr+2,h=1); } } module column(){ column_out(column_width,column_height); translate([20,0,0]) column_in(column_width,column_height); } module base_center(height){ difference(){ cylinder (r=column_width,h=height,$fn=40); width=column_width+0.5; // We raise 1 mm so the column_out does not go through. translate([0,0,1]) union(){ rotate([90,0,0]) profile(getprofile(width+0.5),height+2,6,0,3); //profile([[-width/2,0],[-width/2,width/4],[-width/4,width/2], // [width/4,width/2],[width/2,width/4],[width/2,-width/4], // [width/4,-width/2],[-width/4,-width/2], // [-width/2,-width/4],[-width/2,0]], // ,base_height+2,6,0,3); cylinder(r=column_hole/2+1,h=height+2); } } } module base(){ base_center(base_height); for (i=[0:5]){ rotate([0,0,i*60]) translate([5/2,column_width-1,0]) rotate([0,-90,0]) triangle_rectangle(base_height/2+7,50,5); } difference(){ cylinder(r=column_width+50,h=5); cylinder(r=column_width+50-10,h=5); } } module test_column_in(width,height){ translate([0,0,column_width/2-0.25]) column_in(width,height); translate([-10,0,0]){ translate([0,-15,0]) cube([20,20,0.5]); translate([0,height-15,0]) cube([20,20,0.5]); } } //testthread(); module main_view(view){ if (view=="holder"){ support(); }else if (view=="column_out"){ column_out(column_width,column_height); }else if (view=="column_out_pin"){ column_out(column_width,column_height); rotate([0,-90,0]) translate([0,-10,-column_width/2-3]) pin(); }else if (view=="column_in"){ rotate ([0,0,90]) test_column_in(column_width,column_height); }else if (view=="attach"){ attach(); }else if (view=="tests"){ //translate([0,0,column_width/2+3]) column_out(column_width,10); translate ([50,0,0]) test_column_in(column_width,50); // translate ([100,0,0]) base_center(10); //translate ([0,50,0]) attach(); }else if (view=="test_column_out"){ translate([0,0,column_width/2+3]) column_out(column_width,20); }else if (view=="test_column_in"){ column_in(column_width,10); }else if (view=="base"){ base(); }else if (view=="testbase"){ base_center (10); }else if (view=="attach"){ attach(); } }