From ColdSphinX, 3 Years ago, written in AutoCAD/IntelliCAD Lisp.
Embed
  1. echo("Version:",version());
  2.  
  3. box_length=230;
  4. box_width=155;
  5. box_height=34.25;
  6. xboxes=5;
  7. yboxes=2;
  8. wall_thickness=3;
  9. lid_thickness=2;
  10.  
  11. module pocket(x=0,y=0){
  12.   pocket_length=((box_length-((xboxes+1)*wall_thickness))/xboxes);
  13.   //echo("pocket_length:",pocket_length);
  14.   pocket_width=((box_width-((yboxes+1)*wall_thickness))/yboxes);
  15.   //echo("pocket_width:",pocket_width);
  16.   pocket_height=(box_height-wall_thickness-lid_thickness);
  17.   //echo("pocket_height:",pocket_height);
  18.   translate([(wall_thickness+(x*(pocket_length+wall_thickness))),(wall_thickness+(y*(pocket_width+wall_thickness))),wall_thickness])
  19.     cube([pocket_length,pocket_width,pocket_height]);
  20. }
  21.  
  22. module stacking_form(phase_index=1) {
  23.   polyhedron(points = [
  24.             [box_length,wall_thickness,0],                  // 0 left down front
  25.             [box_length,(box_width-wall_thickness),0],      // 1 right down front
  26.             [wall_thickness,(box_width-wall_thickness),0],  // 2 right down back
  27.             [wall_thickness,wall_thickness,0],              // 3 left down back
  28.             [box_length,0,(wall_thickness*phase_index)],         // 4 left up front
  29.             [box_length,box_width,(wall_thickness*phase_index)], // 5 right up front
  30.             [0,box_width,(wall_thickness*phase_index)],          // 6 right up back
  31.             [0,0,(wall_thickness*phase_index)]                   // 7 left up back
  32.            ],faces = [
  33.             [0,1,2,3],  // bottom
  34.             [4,5,1,0],  // front
  35.             [7,6,5,4],  // top
  36.             [5,6,2,1],  // right
  37.             [6,7,3,2],  // back
  38.             [7,4,0,3]   // left
  39.   ]);
  40. }
  41.  
  42. module lid(cut=0) {
  43.   translate([0,box_width,0])
  44.     rotate([180,0,0])
  45.       polyhedron(points = [
  46.             [(box_length-cut),wall_thickness,0],                                  // 0 left down front
  47.             [(box_length-cut),(box_width-wall_thickness-cut),0],                  // 1 right down front
  48.             [wall_thickness,(box_width-wall_thickness-cut),0],                    // 2 right down back
  49.             [wall_thickness,wall_thickness,0],                                    // 3 left down back
  50.             [(box_length-cut),(wall_thickness/2),lid_thickness],                  // 4 left up front
  51.             [(box_length-cut),(box_width-(wall_thickness/2)-cut),lid_thickness], // 5 right up front
  52.             [(wall_thickness/2),(box_width-(wall_thickness/2)-cut),lid_thickness],// 6 right up back
  53.             [(wall_thickness/2),(wall_thickness/2),lid_thickness]                 // 7 left up back
  54.            ],faces = [
  55.             [0,1,2,3],  // bottom
  56.             [4,5,1,0],  // front
  57.             [7,6,5,4],  // top
  58.             [5,6,2,1],  // right
  59.             [6,7,3,2],  // back
  60.             [7,4,0,3]   // left
  61.       ]);
  62. }
  63.  
  64. module top(phase_index=1){
  65.   translate([0,0,(box_height-wall_thickness)])
  66.     stacking_form(phase_index);
  67.   translate([0,0,(box_height-wall_thickness)])
  68.     lid();
  69.     //cube([(box_length-(wall_thickness/2)),(box_width-wall_thickness),lid_thickness],false);
  70. }
  71.  
  72. module stacking_phase(phase_index=1) {
  73.   difference() {
  74.     cube([box_length,box_width,(wall_thickness*phase_index)],false);
  75.     stacking_form(phase_index);
  76.   }
  77. }
  78.  
  79. difference() {
  80.   color("grey")
  81.   cube([box_length,box_width,box_height],false);
  82.   union(){
  83.     color("red")
  84.     top(1.1);
  85.     color("orange")
  86.     stacking_phase(1);
  87.     for(x = [0:xboxes])
  88.       for(y = [0:yboxes])
  89.         pocket(x,y);
  90.   }  
  91. }
  92.  
  93. //translate([0,(box_width+5),lid_thickness])
  94. //  lid(1);
  95.