$fn = 64; // --- Parameters --- tray_width = 200; // Total width of the organizer tray_length = 150; // Total length of the organizer tray_height = 25; // Total height (designed to fit inside a game box lid) wall_thickness = 2; // Thickness of outer and dividing walls floor_thickness = 2; // Thickness of the bottom floor columns = 4; // Number of compartments horizontally rows = 3; // Number of compartments vertically corner_radius = 4; // Radius for the rounded corners // --- Helper Module --- module rounded_box(w, l, h, r) { // Ensure radius is not larger than half the width/length to prevent geometry errors safe_r = min(r, w/2.01, l/2.01); hull() { translate([safe_r, safe_r, 0]) cylinder(h=h, r=safe_r); translate([w-safe_r, safe_r, 0]) cylinder(h=h, r=safe_r); translate([safe_r, l-safe_r, 0]) cylinder(h=h, r=safe_r); translate([w-safe_r, l-safe_r, 0]) cylinder(h=h, r=safe_r); } } // --- Main Geometry --- difference() { // Main outer body rounded_box(tray_width, tray_length, tray_height, corner_radius); // Calculate individual compartment dimensions comp_w = (tray_width - (wall_thickness * (columns + 1))) / columns; comp_l = (tray_length - (wall_thickness * (rows + 1))) / rows; // Subtract compartments for(c = [0 : columns - 1]) { for(r = [0 : rows - 1]) { x_pos = wall_thickness + c * (comp_w + wall_thickness); y_pos = wall_thickness + r * (comp_l + wall_thickness); // Translate each compartment cutout, adding extra height to prevent Z-fighting translate([x_pos, y_pos, floor_thickness]) rounded_box(comp_w, comp_l, tray_height + 1, corner_radius); } } }