$fn=64; // --- Parameters --- batt_diam = 11.2; // AAA battery diameter + clearance batt_depth = 25.0; // Depth of the slots rows = 3; // Number of rows cols = 4; // Number of columns (12 batteries total) wall_thick = 2.5; // Outer wall thickness spacing = 2.0; // Spacing between batteries floor_thick = 2.0; // Bottom thickness // --- Calculated Dimensions --- box_w = (cols * batt_diam) + ((cols - 1) * spacing) + (2 * wall_thick); box_d = (rows * batt_diam) + ((rows - 1) * spacing) + (2 * wall_thick); box_h = batt_depth + floor_thick; difference() { // Main Body (Rounded Box) hull() { for(x = [wall_thick, box_w - wall_thick]) { for(y = [wall_thick, box_d - wall_thick]) { translate([x, y, 0]) cylinder(r=wall_thick, h=box_h); } } } // Battery Slots and Labels for (r = [0 : rows - 1]) { for (c = [0 : cols - 1]) { x_pos = wall_thick + (batt_diam / 2) + c * (batt_diam + spacing); y_pos = wall_thick + (batt_diam / 2) + r * (batt_diam + spacing); // The slot cylinder translate([x_pos, y_pos, floor_thick]) cylinder(h = box_h + 1, d = batt_diam); // Slot number debossed into the floor of each slot num = r * cols + c + 1; translate([x_pos, y_pos, floor_thick - 0.6]) linear_extrude(1) text(str(num), size=5, halign="center", valign="center", font="Arial:style=Bold"); } } // Main "AAA" label debossed on the front face translate([box_w / 2, 1, box_h / 2]) rotate([90, 0, 0]) linear_extrude(2) text("AAA", size=10, halign="center", valign="center", font="Arial:style=Bold"); }