// Parameters
$diameter_hole =3.2;
$indent_width = 2;
$diameter_z = 6;
$length_base= 7;
$length_hat= 2;
$delta_hole = 4;
$diameter_shaft = 2.5;
$length_blocker = 5;
$height_blocker = $length_blocker + ($length_base - ($delta_hole + ($diameter_hole/2))) + ($diameter_hole-$diameter_shaft) - 0.2;
$diameter_blocker = 10;
$radial_indent = 1;
$slack = 0.2;
$mini_slack = 0.001;

// rendering precision
$fn = $preview ? 32 : 64;

// base
difference() {
    cylinder($length_base, $diameter_z / 2, $diameter_z / 2);
    translate([0, 0 , $delta_hole]) rotate([90, 0, 0])
        cylinder(6,$diameter_hole/2, $diameter_hole/2, center=true);
}

// first half-top
translate([0, 0, $length_base - $mini_slack])
difference() {
    cylinder($length_blocker, $diameter_z / 2, $diameter_z / 2);
    translate([-$indent_width / 2,-5, -$mini_slack])
        cube(10);
}

// second half-top
translate([0,0,$length_base - $mini_slack])
rotate([0,0,180])
difference() {
    cylinder($length_blocker, $diameter_z / 2, $diameter_z / 2);
    translate([-$indent_width / 2,-5, -$mini_slack])
        cube(10);
}

// first half-hat
translate([0,0,$length_base + $length_blocker - $mini_slack])
rotate([0,0,180])
difference() {
    cylinder(2, $radial_indent + $diameter_z / 2,$diameter_z / 2);
    translate([-$indent_width / 2,-5, -$mini_slack])
        cube(10);
}

// second half-hat
translate([0,0,$length_base + $length_blocker - $mini_slack])
difference() {
    cylinder($length_hat, $diameter_z / 2 + $radial_indent, $diameter_z / 2);
    translate([-$indent_width / 2, -5, -$mini_slack])
        cube(10);
}

// blocking piece
translate([20,0,0])
difference() {
    cylinder($height_blocker, $diameter_blocker / 2, $diameter_blocker / 2);
    translate([0, 0, -$mini_slack])
        cylinder($height_blocker + $slack, $diameter_z / 2 + $slack, $diameter_z / 2 + $slack);
}