use ; use ; /* [Size] */ // Width of the rail in increments of 15mm width = 15; // [15:15:300] // Length in increments of 15mm length = 15; // [15:15:300] // Diameter of the hinge tube diameter = 8; // [6:0.5:30] /* [Hinge] */ // Split of the hinge tube: none (half), outer (two ends) or inner (middle) split = "none"; // [none, outer, inner] // Length of each outer part when split (0 = length / 4) outerSplit = 0; // [0:0.5:150] // Flip the rail flip = false; // Screw holes in the rail holes = true; // Height of the nut in the hinge tube nutHeight = 3; // [0.5:0.5:10] railHinge(width, length, d=diameter, split=split, flip=flip, nutHeight=nutHeight, holes=holes, outerSplit=outerSplit > 0 ? outerSplit : undef); module railHinge(w = 15, l = 15, d = 8, split = false, flip = false, nutHeight = 3, holes = true, outerSplit) { gu = 15; ru = 4; cr = 1; e = 0.01; t = 0.2; _outerSplit = is_undef(outerSplit) ? l / 4 : outerSplit; holePattern = [ for (i = [0:floor(l / 15) - 1]) [ for (i = [0:floor(w / 15) - 1]) holes, ], ]; module tube(height, offset = 0, nut = true, flipScrew = false) { translate([w + d / 2, offset, d / 2]) rotate([-90, 0, 0]) difference() { cylinder(h=height, d=d, $fn=32); screw(h=height, nut1=flipScrew && nut ? nutHeight : false, nut2=!flipScrew && nut ? nutHeight : false); } } module removeOverhang(length, offset = 0) { translate([w, offset, -e]) cube([d, length, ru + 2 * e]); } difference() { translate([0, l, ru]) rotate([180, 0, 0]) rail(w + d / 2, l, holes=holePattern, alignX="start", flip=flip); translate([w + d / 2, l + e, d / 2]) rotate([90, 0, 0]) cylinder(h=l + 2 * e, d=d - 2 * e, $fn=32); if (split == "outer") { removeOverhang(l - 2 * _outerSplit + 2 * t, _outerSplit - t); } else if (split == "inner") { removeOverhang(_outerSplit + t); removeOverhang(_outerSplit + t, l - _outerSplit - t); } else { removeOverhang(l / 2, l / 2); } } if (split == "outer") { tube(_outerSplit - t); tube(_outerSplit - t, l - _outerSplit + t, flipScrew=true); } else if (split == "inner") { tube(l - 2 * _outerSplit - 2 * t, _outerSplit + t, nut=false); } else { tube(l / 2); } }