$fn = 64; // --- Parameters --- rail_length = 500; rail_width = 40; rail_depth = 15; // Dovetail settings dt_bottom_w = 26; dt_top_w = 16; dt_depth = 8; // Mounting hole settings hole_spacing = 100; hole_start = 50; screw_shaft_d = 5; screw_head_d = 10; countersink_h = 3; difference() { // Main Rail Body cube([rail_length, rail_width, rail_depth]); // Dovetail Cutout // Profile is drawn in XY, extruded along Z, then rotated to run along X translate([-1, rail_width / 2, rail_depth - dt_depth]) rotate([0, 90, 0]) linear_extrude(height = rail_length + 2) polygon([ [0, -dt_bottom_w / 2], [0, dt_bottom_w / 2], [-dt_depth - 0.1, dt_top_w / 2], [-dt_depth - 0.1, -dt_top_w / 2] ]); // Mounting Holes for (x = [hole_start : hole_spacing : rail_length - 1]) { translate([x, rail_width / 2, -0.1]) { // Screw shaft cylinder(h = rail_depth + 0.2, d = screw_shaft_d); // Countersink for screw head translate([0, 0, rail_depth - dt_depth - countersink_h + 0.1]) cylinder(h = countersink_h, d1 = screw_shaft_d, d2 = screw_head_d); // Clearance for screw head inside the dovetail slot translate([0, 0, rail_depth - dt_depth + 0.1]) cylinder(h = dt_depth + 0.2, d = screw_head_d); } } }