$fn=64; // --- Parameters --- unit_height = 10; // Height of a single unit in mm height_units = 3; // Total height in units hole_inradius = 15; // Inner radius (apothem) of each hex compartment wall_thickness = 2; // Thickness of the walls between hexes floor_thickness = 2; // Thickness of the solid bottom floor // --- Calculated Variables --- total_height = unit_height * height_units; spacing = 2 * hole_inradius + wall_thickness; // Calculate outer and inner cylinder radii for 6-sided polygons // We rotate by 30 degrees later, so the radius is measured to the points hole_r = hole_inradius / cos(30); outer_r = (spacing / 2) / cos(30) + 0.05; // +0.05 ensures manifold overlap for the union // --- Main Model --- difference() { // Outer solid honeycomb structure (19 hexes) union() { for(q = [-2 : 2], r = [-2 : 2]) { // Hexagonal grid condition for a 2-ring cluster (1 + 6 + 12 = 19 hexes) if(abs(q + r) <= 2) { // Axial to Cartesian coordinate conversion translate([spacing * (q + r/2), spacing * sqrt(3)/2 * r, 0]) rotate([0, 0, 30]) cylinder(r=outer_r, h=total_height, $fn=6); } } } // Inner storage compartments to subtract for(q = [-2 : 2], r = [-2 : 2]) { if(abs(q + r) <= 2) { // Shifted up by floor_thickness to leave a solid base translate([spacing * (q + r/2), spacing * sqrt(3)/2 * r, floor_thickness]) rotate([0, 0, 30]) // Over-extend height by 1mm to ensure a clean top cutout (no Z-fighting) cylinder(r=hole_r, h=total_height + 1, $fn=6); } } }