$fn=64; // --- Parameters --- columns = 3; rows = 2; total_width = 150; // mm total_depth = 100; // mm height = 40; // mm wall_thickness = 2; // mm bottom_thickness = 2; // mm corner_radius = 4; // mm // Calculated dimensions comp_width = (total_width - (wall_thickness * (columns + 1))) / columns; comp_depth = (total_depth - (wall_thickness * (rows + 1))) / rows; inner_radius = max(1, corner_radius - wall_thickness); // --- Modules --- module rounded_box(w, d, h, r) { hull() { translate([r, r, 0]) cylinder(r=r, h=h); translate([w-r, r, 0]) cylinder(r=r, h=h); translate([r, d-r, 0]) cylinder(r=r, h=h); translate([w-r, d-r, 0]) cylinder(r=r, h=h); } } // --- Main Geometry --- difference() { // Outer Shell rounded_box(total_width, total_depth, height, corner_radius); // Inner Compartments for (c = [0 : columns - 1]) { for (r = [0 : rows - 1]) { x_pos = wall_thickness + c * (comp_width + wall_thickness); y_pos = wall_thickness + r * (comp_depth + wall_thickness); z_pos = bottom_thickness; // Subtraction with +1 height to prevent Z-fighting at the top translate([x_pos, y_pos, z_pos]) rounded_box(comp_width, comp_depth, height + 1, inner_radius); } } }