$fn = 64; // --- Parameters --- rail_length = 600; // Total length of the rail rail_width = 40; // Width of the rail against the wall rail_depth = 12; // Total thickness/depth of the rail bevel_width = 5; // Width of the dovetail chamfer lap_length = 15; // Length of the interlocking half-lap joint hole_count = 6; // Number of mounting holes hole_spacing = 100; // Distance between mounting holes screw_dia = 5.5; // Clearance hole for M5 screw screw_head_dia = 10.5; // Diameter of the countersink screw_head_depth = 3; // Depth of the countersink cone // --- Main Model --- difference() { // Main rail profile (Dovetail/French Cleat style) rotate([0, 90, 0]) translate([0, 0, -rail_length / 2]) linear_extrude(rail_length) polygon([ [0, -rail_width / 2], [0, rail_width / 2], [-rail_depth, rail_width / 2 - bevel_width], [-rail_depth, -rail_width / 2 + bevel_width] ]); // Mounting holes distributed along the rail start_x = - (hole_spacing * (hole_count - 1)) / 2; for (i = [0 : hole_count - 1]) { translate([start_x + i * hole_spacing, 0, -1]) { // Clearance hole for screw thread cylinder(h = rail_depth + 2, d = screw_dia); // Countersink for screw head translate([0, 0, rail_depth - screw_head_depth + 1]) cylinder(h = screw_head_depth + 0.01, d1 = screw_dia, d2 = screw_head_dia); // Counterbore to ensure screw head is fully recessed or flush translate([0, 0, rail_depth + 1]) cylinder(h = 2, d = screw_head_dia); } } // Interlocking half-lap joint (Right End - Top Cut) // Allows seamless extension with multiple printed pieces translate([rail_length / 2 - lap_length, -rail_width, rail_depth / 2]) cube([lap_length + 1, rail_width * 2, rail_depth]); // Interlocking half-lap joint (Left End - Bottom Cut) translate([-rail_length / 2 - 1, -rail_width, -1]) cube([lap_length + 1, rail_width * 2, rail_depth / 2 + 1]); }