$fn = 64; // --- Parameters --- // Outer dimensions of the bin (Default: 84x84mm for standard 2x2 modular bins) bin_width = 84.0; bin_length = 84.0; corner_radius = 4.0; // Lid dimensions wall_thickness = 1.6; top_thickness = 1.6; skirt_height = 8.0; // Fitment and snap mechanics clearance = 0.25; snap_lip = 0.5; // --- Modules --- module rounded_box(w, l, h, r) { safe_r = min(r, w/2, l/2); if (safe_r > 0) { hull() { translate([-w/2+safe_r, -l/2+safe_r, 0]) cylinder(r=safe_r, h=h); translate([ w/2-safe_r, -l/2+safe_r, 0]) cylinder(r=safe_r, h=h); translate([-w/2+safe_r, l/2-safe_r, 0]) cylinder(r=safe_r, h=h); translate([ w/2-safe_r, l/2-safe_r, 0]) cylinder(r=safe_r, h=h); } } else { translate([-w/2, -l/2, 0]) cube([w, l, h]); } } // --- Main Geometry --- difference() { // Outer shell rounded_box( bin_width + 2*clearance + 2*wall_thickness, bin_length + 2*clearance + 2*wall_thickness, skirt_height + top_thickness, corner_radius + clearance + wall_thickness ); // Inner cavity - Main clearance area translate([0, 0, 1.49]) rounded_box( bin_width + 2*clearance, bin_length + 2*clearance, skirt_height - 1.49, corner_radius + clearance ); // Inner cavity - 45-degree chamfer for printable snap fit hull() { translate([0, 0, 0.49]) rounded_box( bin_width + 2*clearance - 2*snap_lip, bin_length + 2*clearance - 2*snap_lip, 0.01, corner_radius + clearance - snap_lip ); translate([0, 0, 1.5]) rounded_box( bin_width + 2*clearance, bin_length + 2*clearance, 0.01, corner_radius + clearance ); } // Inner cavity - Bottom lip area (snaps under the rim) translate([0, 0, -0.01]) rounded_box( bin_width + 2*clearance - 2*snap_lip, bin_length + 2*clearance - 2*snap_lip, 0.51, corner_radius + clearance - snap_lip ); }