$fn=64; // --- PARAMETERS --- grid_x = 4; // Number of units in X direction grid_y = 4; // Number of units in Y direction unit_size = 42.0; // Size of a single grid unit (42mm for standard modular bins) clearance = 0.6; // Clearance to easily fit over the bin wall_thickness = 2.0; // Thickness of the outer lip top_thickness = 2.0; // Thickness of the top cover lip_height = 8.0; // Depth of the lip that goes over the bin corner_radius = 4.0; // Outer corner radius snap_ridge = 0.6; // Depth of the inner snap ridge // --- CALCULATED DIMENSIONS --- in_w = (grid_x * unit_size) + clearance; in_d = (grid_y * unit_size) + clearance; out_w = in_w + (2 * wall_thickness); out_d = in_d + (2 * wall_thickness); // --- MAIN OBJECT --- union() { difference() { // Main outer body rounded_rect_centered(out_w, out_d, lip_height + top_thickness, corner_radius + wall_thickness); // Subtracted inner void for the snap fit inner_void(); } // Top reinforcing ridge for stiffness and stacking translate([0, 0, lip_height + top_thickness]) difference() { rounded_rect_centered(out_w, out_d, 1.5, corner_radius + wall_thickness); translate([0, 0, -0.1]) rounded_rect_centered(out_w - 6, out_d - 6, 1.7, corner_radius + wall_thickness - 3); } } // --- MODULES --- // Creates the profiled inner cavity to allow a snap-on fit without supports module inner_void() { lip_w = in_w - (2 * snap_ridge); lip_d = in_d - (2 * snap_ridge); // 1. Bottom entry flare (helps guide the lid onto the bin) hull() { translate([0, 0, -0.1]) rounded_rect_centered(in_w + 2, in_d + 2, 0.1, corner_radius + 1); translate([0, 0, 1.2]) rounded_rect_centered(lip_w, lip_d, 0.1, corner_radius); } // 2. Tight snap lip translate([0, 0, 1.2]) rounded_rect_centered(lip_w, lip_d, 1.0, corner_radius); // 3. 45-degree transition to the looser main cavity (printable without supports) hull() { translate([0, 0, 2.2]) rounded_rect_centered(lip_w, lip_d, 0.1, corner_radius); translate([0, 0, 2.2 + snap_ridge]) rounded_rect_centered(in_w, in_d, 0.1, corner_radius + snap_ridge); } // 4. Main looser cavity translate([0, 0, 2.2 + snap_ridge]) rounded_rect_centered(in_w, in_d, lip_height, corner_radius + snap_ridge); } // Helper module for a centered rounded rectangle module rounded_rect_centered(w, d, h, r) { translate([-w/2, -d/2, 0]) hull() { translate([r, r, 0]) cylinder(r=r, h=h); translate([w-r, r, 0]) cylinder(r=r, h=h); translate([w-r, d-r, 0]) cylinder(r=r, h=h); translate([r, d-r, 0]) cylinder(r=r, h=h); } }