$fn = 50; tube_length = 4; // tube length in studs piston_length = 3; // piston length in studs travel_length = piston_length-2; // piston travel in studs top_type = "axle"; // top mounting type: 'pin' = pin hole, 'ball' = ball end hole, 'axle' = axle hole, "axle_rod" = axle, "ball_end" = ball bottom_type = "ball"; // bottom mounting type travel = min(travel_length, piston_length-2, tube_length-2); //difference() { union() { difference() { tube_offset = (bottom_type == "axle" || bottom_type == "axle_rod" ? 1 : (bottom_type == "ball_end" ? 0.4 : 0)); union() { translate([0, 0, 8]) cylinder(r=4, h=tube_length*8-8); mount_base(type=bottom_type, r=4); } mount_hole(bottom_type); translate([0, 0, 8+tube_offset]) cylinder(r=3.2, h=tube_length*8-tube_offset); translate([-5, -0.5, tube_length*8-6]) cube(size=[10, 1, 3], center=false); } color([1, 0.5, 0.5]) translate([0, 0, (tube_length+piston_length-1)*8]) rotate([180, 0, 0]) { difference() { union() { //translate([0, 0, 4]) cylinder(r=3, h=piston_length*8-4); //rotate([90, 0, 0]) translate([0, 4, -4]) cylinder(r=4, h=8); translate([0, 0, 8]) cylinder(r=3, h=piston_length*8-8); mount_base(top_type); } mount_hole(top_type); translate([-5, -0.7, (piston_length-travel-1)*8+3]) cube(size=[10, 1.4, travel*8+3], center=false); } } //rotate([90, 0, 0]) color([0.5, 0.5, 1]) translate([-4, -0.5, tube_length*8-6]) cube(size=[8, 1, 3], center=false); //} translate([0, -50, -1]) cube(size=[10, 500, 500]); } //rotate([10, 0, 0]) axleround(h=8); module mount_base(type, r = 3) { if (type == "pin" || type == "ball" || type == "axle") { cylinder(r=4, h=8+0.1); } else if (type == "axle_rod") { axleround(h=8+0.1); } else if (type == "ball_end") { translate([0, 0, 4]) sphere(r=3); translate([0, 0, 6]) linear_extrude(scale=r, height=2) circle(r=1); } } module mount_hole(type) { if (type == "pin") { rotate([90, 0, 0]) translate([0, 4, -4]) pin_hole(); } else if (type == "ball") { ball_end_n(); } else if (type == "axle") { translate([0, 0, -0.1]) axleround(h=8+0.1, axleradius=2.4, axlemesh=1.85); translate([0, 0, -0.1]) cylinder($fs=0.5, h=0.8+0.1, r=5); } } // cut for ball end module ball_end_n() { translate([0, 0, 4]) sphere(r=3.05); translate([0, 0, 2.3-0.1]) cylinder(r=2.9, h=2); translate([0, 0, -0.1]) cylinder(r=5, h=2.4); } module axleround(h = 24, axleradius = 2.3, axlemesh = 1.7) { difference() { cylinder($fn=16, r=axleradius, h=h); translate([axlemesh/2, axlemesh/2, -1]) cube([axleradius, axleradius, h+2]); translate([axlemesh/2, -axlemesh/2-axleradius, -1]) cube([axleradius, axleradius, h+2]); translate([-axlemesh/2-axleradius, axlemesh/2, -1]) cube([axleradius, axleradius, h+2]); translate([-axlemesh/2-axleradius, -axlemesh/2-axleradius, -1]) cube([axleradius, axleradius, h+2]); } } module pin_hole(height=8) { union() { translate([0, 0, -0.1]) cylinder($fs=0.5, h=height+0.2, r=2.5); translate([0, 0, -0.1]) cylinder($fs=0.5, h=0.8+0.1, r=3); translate([0, 0, height-0.8]) cylinder($fs=0.5, h=0.8+0.1, r=3); } }