From ColdSphinX, 7 Years ago, written in AutoCAD/IntelliCAD Lisp.
This paste is a reply to sorting box final from ColdSphinX - view diff
Embed
  1. box_length=230;
  2. box_width=155;
  3. box_height=34.25;
  4. xboxes=5;
  5. yboxes=2;
  6. wall_thickness=3;
  7. lid_thickness=2;
  8.  
  9. module pocket(x=0,y=0){
  10.   pocket_length=((box_length-((xboxes+1)*wall_thickness))/xboxes);
  11.   //echo("pocket_length:",pocket_length);
  12.   pocket_width=((box_width-((yboxes+1)*wall_thickness))/yboxes);
  13.   //echo("pocket_width:",pocket_width);
  14.   pocket_height=(box_height-wall_thickness-lid_thickness);
  15.   //echo("pocket_height:",pocket_height);
  16.   translate([(wall_thickness+(x*(pocket_length+wall_thickness))),(wall_thickness+(y*(pocket_width+wall_thickness))),wall_thickness])
  17.     cube([pocket_length,pocket_width,pocket_height]);
  18. }
  19.  
  20. module stacking_form(phase_index=1) {
  21.   polyhedron(points = [
  22.             [box_length,wall_thickness,0],                  // 0 left down front
  23.             [box_length,(box_width-wall_thickness),0],      // 1 right down front
  24.             [wall_thickness,(box_width-wall_thickness),0],  // 2 right down back
  25.             [wall_thickness,wall_thickness,0],              // 3 left down back
  26.             [box_length,0,(wall_thickness*phase_index)],         // 4 left up front
  27.             [box_length,box_width,(wall_thickness*phase_index)], // 5 right up front
  28.             [0,box_width,(wall_thickness*phase_index)],          // 6 right up back
  29.             [0,0,(wall_thickness*phase_index)]                   // 7 left up back
  30.            ],faces = [
  31.             [0,1,2,3],  // bottom
  32.             [4,5,1,0],  // front
  33.             [7,6,5,4],  // top
  34.             [5,6,2,1],  // right
  35.             [6,7,3,2],  // back
  36.             [7,4,0,3]   // left
  37.   ]);
  38. }
  39.  
  40. module lid_nose(cut=0) {
  41.   nose_length=((box_length/10)-cut);
  42.   nose_width=((wall_thickness-cut)/2);
  43.   nose_height=(1-(cut/2));
  44.   translate([(box_length-cut-(nose_width*1.5)),((box_width/2)-(nose_length/2)),(-nose_height-lid_thickness)])
  45.     cube([nose_width,nose_length,nose_height+1]);
  46. }
  47.  
  48. module lid_opener(cut=0) {
  49.   opener_length=(box_length/5);
  50.   opener_width=(wall_thickness-cut)/4;
  51.   opener_height=(lid_thickness/2);
  52.   translate([(box_length-cut-opener_width),((box_width/2)-(opener_length/2)),(-lid_thickness)])
  53.     cube([opener_width,opener_length,opener_height]);
  54. }
  55.  
  56. module lid_grab(cut=0) {
  57.   grab_length=(box_length/5);
  58.   grab_width=(lid_thickness*2);
  59.   grab_height=(lid_thickness/2);
  60.   translate([(box_length-(2*grab_width)),((box_width/2)-(grab_length/2)),0.1])
  61.     rotate([180,0,90])
  62.     polyhedron(points = [
  63.           [0,0,0],
  64.           [grab_length,0,0],
  65.           [grab_length,grab_width,0],
  66.           [0,grab_width,0],
  67.           [0,(grab_width/2),grab_height],
  68.           [grab_length,(grab_width/2),grab_height]
  69.         ],
  70.         faces=[
  71.           [0,1,2,3],
  72.           [5,4,3,2],
  73.           [0,4,5,1],
  74.           [0,3,4],
  75.           [5,2,1]
  76.       ]);
  77.     //cube([grab_width,grab_length,grab_height]);
  78. }
  79.  
  80. module lid_base(cut=0) {
  81.   translate([0,box_width,0])
  82.     rotate([180,0,0])
  83.       polyhedron(points = [
  84.         [(box_length-cut),wall_thickness,0],                                  // 0 left down front
  85.         [(box_length-cut),(box_width-wall_thickness-cut),0],                  // 1 right down front
  86.         [wall_thickness,(box_width-wall_thickness-cut),0],                    // 2 right down back
  87.         [wall_thickness,wall_thickness,0],                                    // 3 left down back
  88.         [(box_length-cut),(wall_thickness/2),lid_thickness],                  // 4 left up front
  89.         [(box_length-cut),(box_width-(wall_thickness/2)-cut),lid_thickness],  // 5 right up front
  90.         [(wall_thickness/2),(box_width-(wall_thickness/2)-cut),lid_thickness],// 6 right up back
  91.         [(wall_thickness/2),(wall_thickness/2),lid_thickness]                 // 7 left up back
  92.         ],faces = [
  93.         [0,1,2,3],  // bottom
  94.         [4,5,1,0],  // front
  95.         [7,6,5,4],  // top
  96.         [5,6,2,1],  // right
  97.         [6,7,3,2],  // back
  98.         [7,4,0,3]   // left
  99.       ]);
  100.   lid_nose(cut);
  101. }
  102.  
  103. module lid(cut=0) {
  104.   if (cut > 0) {
  105.     difference() {
  106.       lid_base(cut);
  107.       lid_opener(cut);
  108.       lid_grab(cut);
  109.     }
  110.   } else {
  111.     lid_base(cut);
  112.   }
  113. }
  114.  
  115. module top(phase_index=1){
  116.   translate([0,0,(box_height-wall_thickness)])
  117.     stacking_form(phase_index);
  118.   translate([0,0,(box_height-wall_thickness)])
  119.     lid();
  120. }
  121.  
  122. module stacking_phase(phase_index=1) {
  123.   difference() {
  124.     cube([box_length,box_width,(wall_thickness*phase_index)],false);
  125.     stacking_form(phase_index);
  126.   }
  127. }
  128. /**/
  129. difference() {
  130.   color("grey")
  131.   cube([box_length,box_width,box_height],false);
  132.   union(){
  133.     color("red")
  134.     top(1.1);
  135.     color("orange")
  136.     stacking_phase(1);
  137.     for(x = [0:xboxes])
  138.       for(y = [0:yboxes])
  139.         pocket(x,y);
  140.   }  
  141. }
  142. /**/
  143. translate([0,(-5),0])
  144.   rotate([180,0,0])
  145.     lid(1);
  146. /**/

Replies to sorting box final rss

Title Name Language When
ultimate sorting box ColdSphinX cadlisp 7 Years ago.