$fn=64; // --- Parameters --- rail_length = 500; rail_base_width = 30; // Width against the wall rail_top_width = 40; // Width at the front (creates a printable dovetail) rail_thickness = 10; // Depth of the rail hole_spacing = 100; // Distance between mounting holes hole_diameter = 4.5; // Clearance for M4 or #8 screws countersink_diameter = 9; // Diameter of screw head countersink_depth = 3; // Depth of the angled screw head // --- Main Model --- module wall_rail() { difference() { // Main rail profile (dovetail/chamfered shape) translate([0, -rail_length/2, 0]) rotate([-90, 0, 0]) linear_extrude(height=rail_length) polygon([ [-rail_base_width/2, 0], [rail_base_width/2, 0], [rail_top_width/2, rail_thickness], [-rail_top_width/2, rail_thickness] ]); // Mounting holes num_holes = floor(rail_length / hole_spacing); start_y = -(num_holes - 1) * hole_spacing / 2; for (i = [0 : num_holes - 1]) { translate([0, start_y + i * hole_spacing, 0]) { // Screw shaft clearance translate([0, 0, -1]) cylinder(h=rail_thickness + 2, d=hole_diameter); // Countersink angled cone translate([0, 0, rail_thickness - countersink_depth]) cylinder(h=countersink_depth + 0.01, d1=hole_diameter, d2=countersink_diameter); // Countersink top clearance (ensures manifold subtraction) translate([0, 0, rail_thickness]) cylinder(h=2, d=countersink_diameter); } } } } // Render the object wall_rail();