$fn = 64; // --- Parameters --- housing_width = 100; housing_depth = 120; housing_height = 50; wall_thickness = 2; clearance = 0.4; peg_radius = 4; peg_height = 1.5; peg_offset = 12; // Set to true for side-by-side printing layout, false for assembled view print_layout = true; // --- Layout --- if (print_layout) { housing(); translate([housing_width + 10, 0, 0]) drawer(); } else { housing(); // Drawer pulled out slightly to show assembly translate([wall_thickness + clearance, 15, wall_thickness + clearance]) drawer(); } // --- Modules --- module housing() { difference() { union() { // Main housing body cube([housing_width, housing_depth, housing_height]); // Top stacking pegs (Male) for (x = [peg_offset, housing_width - peg_offset]) { for (y = [peg_offset, housing_depth - peg_offset]) { translate([x, y, housing_height]) cylinder(r1=peg_radius - clearance/2, r2=peg_radius - clearance - 0.5, h=peg_height); } } } // Inner cavity (Open at the front, y=0) translate([wall_thickness, -0.1, wall_thickness]) cube([ housing_width - 2*wall_thickness, housing_depth - wall_thickness + 0.1, housing_height - 2*wall_thickness ]); // Bottom stacking holes (Female) for (x = [peg_offset, housing_width - peg_offset]) { for (y = [peg_offset, housing_depth - peg_offset]) { translate([x, y, -0.1]) cylinder(r1=peg_radius + clearance, r2=peg_radius + clearance/2, h=peg_height + 0.2); } } } } module drawer() { d_width = housing_width - 2*wall_thickness - 2*clearance; d_depth = housing_depth - wall_thickness - clearance; d_height = housing_height - 2*wall_thickness - 2*clearance; difference() { // Drawer outer body cube([d_width, d_depth, d_height]); // Drawer inner cavity translate([wall_thickness, wall_thickness, wall_thickness]) cube([ d_width - 2*wall_thickness, d_depth - 2*wall_thickness, d_height ]); // Front handle cutout (Semi-circle at the top edge for support-free printing) translate([d_width / 2, -0.1, d_height]) rotate([-90, 0, 0]) cylinder(r=12, h=wall_thickness + 0.2); } }