$fn=64; // --- Parameters --- total_width = 100; // Total width of the insert (X axis) total_length = 150; // Total length of the insert (Y axis) height = 20; // Total height of the grid wall_thickness = 1.6; // Thickness of the divider walls columns = 4; // Number of compartments in X axis rows = 3; // Number of compartments in Y axis has_base = false; // Set to true to include a solid bottom tray base_thickness = 1.6; // Thickness of the bottom base (if has_base is true) module grid_insert() { // Calculate individual compartment dimensions comp_w = (total_width - (wall_thickness * (columns + 1))) / columns; comp_l = (total_length - (wall_thickness * (rows + 1))) / rows; // Z-axis cut logic to ensure clean manifold subtraction z_offset = has_base ? base_thickness : -1; cut_height = has_base ? height - base_thickness + 1 : height + 2; difference() { // Main solid block cube([total_width, total_length, height]); // Subtract compartments for (x = [0 : columns - 1]) { for (y = [0 : rows - 1]) { x_pos = wall_thickness + x * (comp_w + wall_thickness); y_pos = wall_thickness + y * (comp_l + wall_thickness); translate([x_pos, y_pos, z_offset]) cube([comp_w, comp_l, cut_height]); } } } } grid_insert();