diff --git a/Box_Type2_Generator.scad b/Box_Type2_Generator.scad index 1e51b6b..8dd770e 100644 --- a/Box_Type2_Generator.scad +++ b/Box_Type2_Generator.scad @@ -10,7 +10,7 @@ // generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z); // generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, [NOTCH_WIDTH, NOTCH_DEPTH]); // Small example for a box width inner size 60x60x30, wall size 4, wall-sized overlap and a small notch: -generate_box(60, 60, 30, 4, 4, 5, 2); +generate_box(60, 60, 30, 4, 4, 5, 2, body=true, lid=true); /* * [2] Include & Generate * Copy and paste this line to another file: */ @@ -28,22 +28,15 @@ generate_box(60, 60, 30, 4, 4, 5, 2); * Idea behind the notch: you can secure the box lid with e.g. a rubber band */ -module generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, NOTCH_WIDTH, NOTCH_DEPTH) { +module generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, NOTCH_WIDTH, NOTCH_DEPTH, BODY, LID) { difference() { union() { - // The main box - difference() { - cube([INNER_X+WALLSIZE*2, INNER_Y+WALLSIZE*2, INNER_Z+WALLSIZE*2]); - translate([WALLSIZE, WALLSIZE, WALLSIZE]) - cube([INNER_X, INNER_Y, INNER_Z+WALLSIZE]); + if(body) { + generate_main_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE); } - - // Box lid - translate([WALLSIZE, WALLSIZE, INNER_Z+WALLSIZE*4]) { - translate([0.5, 0.5, 0]) - cube([INNER_X-1, INNER_Y-1, OVERLAP_Z]); - translate([-WALLSIZE, -WALLSIZE, OVERLAP_Z]) - cube([INNER_X+WALLSIZE*2, INNER_Y+WALLSIZE*2, WALLSIZE]); + if(lid) { + translate([WALLSIZE, WALLSIZE, INNER_Z+WALLSIZE*4]) + generate_lid(INNER_X, INNER_Y, OVERLAP_Z, WALLSIZE); } } @@ -55,4 +48,21 @@ module generate_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE, OVERLAP_Z, NOTCH_WIDTH, cube([NOTCH_WIDTH, NOTCH_DEPTH, INNER_Z+WALLSIZE*6]); } } +} + +// The main box +module generate_main_box(INNER_X, INNER_Y, INNER_Z, WALLSIZE) { + difference() { + cube([INNER_X+WALLSIZE*2, INNER_Y+WALLSIZE*2, INNER_Z+WALLSIZE*2]); + translate([WALLSIZE, WALLSIZE, WALLSIZE]) + cube([INNER_X, INNER_Y, INNER_Z+WALLSIZE]); + } +} + +// Box lid +module generate_lid(INNER_X, INNER_Y, OVERLAP_Z, WALLSIZE) { + translate([0.5, 0.5, 0]) + cube([INNER_X-1, INNER_Y-1, OVERLAP_Z]); + translate([-WALLSIZE, -WALLSIZE, OVERLAP_Z]) + cube([INNER_X+WALLSIZE*2, INNER_Y+WALLSIZE*2, WALLSIZE]); } \ No newline at end of file