use <threads.scad>;
$fn=90;

Debug=false;
Schnitt=false;

/* [Hidden] */

Inch=25.4;
Delta=0.01;

function sump(a,i) = (i==0)?a[0]:a[i]+sump(a,i-1);
function sumt(a) = sump(a,len(a)-1);

intersection() {
  difference() {
    L=[7,1.5,3];
    echo(sum(L,len(L)-1));
    // aussen
    union() {
      metric_thread(diameter=10.9, pitch=1, length=L[0], test=Debug);
      translate([0,0,sump(L,0)]) cylinder(d=10, h=L[1]);
      translate([0,0,sump(L,1)]) intersection() { 
        R=13/sqrt(3);
        cylinder(r=R, h=L[2], $fn=6);
        cylinder(r=R-0.5, h=L[2]);
      }
    }
    // innen
    translate([0,0,-Delta]) metric_thread(diameter=0.305*Inch+0.15, pitch=Inch/32, length=sumt(L)+2*Delta, test=Debug);
  }
  translate([0,(Schnitt)?50:0,0]) cube(100, center=true);
}
