$fn = 64; // --- Parameters --- hex_flat_to_flat = 50; hex_height = 6; // Dovetail joint parameters dovetail_w_in = 10; dovetail_w_out = 16; dovetail_length = 5; tolerance = 0.3; // Clearance for easy interlocking // Calculated point-to-point radius for the hexagon hex_radius = hex_flat_to_flat / sqrt(3); // --- Modules --- module dovetail_male() { polygon([ [-dovetail_w_in/2, 0], [ dovetail_w_in/2, 0], [ dovetail_w_out/2, dovetail_length], [-dovetail_w_out/2, dovetail_length] ]); } module dovetail_female() { // Slightly larger for tolerance, extending outwards to ensure a clean boolean cut polygon([ [-(dovetail_w_in + tolerance)/2, 0.1], [ (dovetail_w_in + tolerance)/2, 0.1], [ (dovetail_w_out + tolerance)/2, -(dovetail_length + tolerance)], [-(dovetail_w_out + tolerance)/2, -(dovetail_length + tolerance)] ]); } // --- Main Geometry --- difference() { union() { // Base Hexagon cylinder(r=hex_radius, h=hex_height, $fn=6); // Add male dovetails on alternating faces (0, 2, 4) for (i = [0, 2, 4]) { rotate([0, 0, i * 60 + 30]) translate([0, hex_flat_to_flat/2 - 0.05, 0]) // Slight overlap for manifold union linear_extrude(height=hex_height) dovetail_male(); } } // Subtract female dovetails on remaining faces (1, 3, 5) for (i = [1, 3, 5]) { rotate([0, 0, i * 60 + 30]) translate([0, hex_flat_to_flat/2, -0.5]) linear_extrude(height=hex_height + 1) // Extended height for clean cut through top/bottom dovetail_female(); } }