$fn=64; // --- Parameters --- wall_thickness = 2; comp_width = 45; comp_depth = 55; comp_height = 30; cols = 3; rows = 2; // Labels for each compartment labels = ["M2", "M3", "M4", "M5", "M6", "M8"]; // Calculate overall dimensions total_width = cols * comp_width + (cols + 1) * wall_thickness; total_depth = rows * comp_depth + (rows + 1) * wall_thickness; total_height = comp_height + wall_thickness; difference() { // Main outer block cube([total_width, total_depth, total_height]); // Subtract compartments and engrave labels for (r = [0 : rows - 1]) { for (c = [0 : cols - 1]) { idx = r * cols + c; // Calculate X and Y positions for the current compartment pos_x = wall_thickness + c * (comp_width + wall_thickness); pos_y = wall_thickness + r * (comp_depth + wall_thickness); // 1. Compartment cutout translate([pos_x, pos_y, wall_thickness]) cube([comp_width, comp_depth, comp_height + 1]); // 2. Label text (embossed 0.5mm into the floor) if (idx < len(labels)) { translate([ pos_x + comp_width / 2, pos_y + comp_depth / 2, wall_thickness - 0.5 ]) linear_extrude(1) text( labels[idx], size = 12, halign = "center", valign = "center", font = "Arial:style=Bold" ); } } } }