use <../cadlib.h> // allviews minibox small-box-4-4 medium-box-3-3 // allviews large-box-3-2 // testviews testbox testbox2 separators include small_cellwidth=40; small_celldepth=30; small_cellheight=20; medium_cellwidth=50; medium_celldepth=40; medium_cellheight=20; large_cellwidth=60; large_celldepth=50; large_cellheight=20; thickwall=vs_nozzle_diameter; thicksep=vs_nozzle_diameter; thickfloor=0.75; forcer=2; stackr=3; rprecision=10; module sidepost(height){ difference(){ cylinder(r=forcer,h=height,$fn=rprecision); union(){ rotate([0,0,180]) translate([-5,0,0]) cube([10,10,3]); rotate([0,0,90]) translate([-5,0,0]) cube([10,10,3]); } } } module separators(width,depth,height,nbrow,nbcol){ // Place the separators with half cylinder to make the floor stronger // First in one direction translate([0,0,thickfloor]){ lenw=nbcol*width; rotate([0,90,0]) quarter_cylinder(forcer,lenw,rprecision,2); for(i=[1:nbrow-1]){ translate([0,i*depth,0]){ cube([lenw,thicksep,height-thickfloor]); rotate([0,90,0]) half_cylinder(forcer,lenw,rprecision,2); translate([thickwall,0,0]) rotate([0,0,90]) half_cylinder(forcer,height,rprecision,3); translate([lenw-thickwall,0,0]) rotate([0,0,90]) half_cylinder(forcer,height,rprecision,1); } } translate([0,nbrow*depth,0]) rotate([0,90,0]) quarter_cylinder(forcer,lenw,rprecision,3); // Next in the other direction lend=nbrow*depth; rotate([0,90,90]) quarter_cylinder(forcer,lend,rprecision,3); for(j=[1:nbcol-1]){ translate([j*width,0,0]){ cube([thicksep,lend,height-thickfloor]); rotate([0,90,90]) half_cylinder(forcer,lend,rprecision,2); translate([0,thickwall,0]) rotate([0,0,90]) half_cylinder(forcer,height,rprecision,4); translate([0,lend-thickwall,0]) rotate([0,0,90]) half_cylinder(forcer,height,rprecision,2); } } translate([nbcol*width,0,0]) rotate([0,90,90]) quarter_cylinder(forcer,lend,rprecision,2); } } module box (width,depth,height,nbrow,nbcol){ difference(){ cube([nbcol*width,nbrow*depth,height]); translate([thickwall,thickwall,thickfloor]) cube([nbcol*width-2*thickwall,nbrow*depth-2*thickwall,height]); } separators(width,depth,height,nbrow,nbcol); // Place the little cylinder to make the top stronger for(i=[0:nbrow]){ translate([0,i*depth,height]) rotate([0,90,0]) cylinder(r=forcer,h=nbcol*width,$fn=rprecision); } for(j=[0:nbcol]){ translate([j*width,0,height]) rotate([-90,0,0]) cylinder(r=forcer,h=nbrow*depth,$fn=rprecision); } // Place cylinder on the 4 corners translate([0,0,0]) sidepost(height); translate([0,nbrow*depth,0]) rotate([0,0,-90])sidepost(height); translate([nbcol*width,nbrow*depth,0]) rotate([0,0,180]) sidepost(height); translate([nbcol*width,0,0]) rotate([0,0,90]) sidepost(height); } module corner(){ translate([-0.5,-1.5,0]){ cube([5.5,1,5]); cube([5.5,1.5,2]); } rotate([0,0,270]) translate([-5,-1.5,0]){ cube([5.5,1,5]); cube([5.5,1.5,2]); } translate([-0.5,-0.5,0]) difference(){ cylinder(r=1,h=5,$fn=rprecision); cube([1,1,10]); } } module stackable(width,depth,height,nbrow,nbcol){ translate([0,0,height-2]) corner(); translate([0,nbrow*depth,height-2]) rotate([0,0,-90]) corner(); translate([nbcol*width,nbrow*depth,height-2]) rotate([0,0,180]) corner(); translate([nbcol*width,0,height-2]) rotate([0,0,90]) corner(); box(width,depth,height,nbrow,nbcol); } module main_view(view){ if (view=="testbox2"){ stackable(10,15,10,2,2); translate([50,0,0]) stackable(10,15,10,2,2); }else if (view=="testbox"){ stackable(10,15,10,2,2); }else if (view=="minibox"){ stackable(20,25,10,2,2); }else if (view=="small-box-4-4"){ stackable(small_cellwidth,small_celldepth,small_cellheight,4,4); }else if (view=="medium-box-3-3"){ stackable(medium_cellwidth,medium_celldepth,medium_cellheight,3,3); }else if (view=="large-box-3-2"){ stackable(large_cellwidth,large_celldepth,large_cellheight,3,2); }else if (view=="separators"){ separators(20,25,10,2,2); } }