$fn=64; // --- Parameters --- rows = 5; // Number of rows cols = 5; // Number of columns cell_w = 12.0; // Width of each cell (mm) cell_l = 12.0; // Length of each cell (mm) cell_d = 8.0; // Depth of the cells (mm) wall_t = 1.2; // Wall thickness between cells (mm) floor_t = 1.2; // Floor thickness (mm) // --- Calculated Dimensions --- total_w = (cols * cell_w) + ((cols + 1) * wall_t); total_l = (rows * cell_l) + ((rows + 1) * wall_t); total_h = cell_d + floor_t; // --- Module Generation --- difference() { // Main outer body cube([total_w, total_l, total_h]); // Subtract the grid of cells for (r = [0 : rows - 1]) { for (c = [0 : cols - 1]) { // Calculate X and Y positions for each cell x_pos = wall_t + c * (cell_w + wall_t); y_pos = wall_t + r * (cell_l + wall_t); // Subtract cell volume // Added 1.0mm to Z height to ensure a clean manifold cut through the top translate([x_pos, y_pos, floor_t]) cube([cell_w, cell_l, cell_d + 1.0]); } } }