use <threads.scad>

// set false for FDM, true for UV-SLA
print_SLA = false; 

// set false to render thread
debug = true;

B=5; // [2:1:10]

$fn=4*36;

intersection() {
  difference() {
    hull() {
      intersection() {
        cylinder(h = 6, r = (20/sqrt(3)), $fn=6);
        cylinder(h = 80, r = 0.95*(20/sqrt(3)), center=true);
      }
      #translate(v = [0,0,27]) {
        rotate([90,0,0]) {
          cylinder(h = 10, d1=18, d2=15);
          mirror([0,0,1]) cylinder(h = 10, d1=18, d2=15);
        }
      }
    }
    #translate(v = [0,0,27]) {
      rotate([90,0,0]) {
        cylinder(h = 25, d=7.5, center=true);
        translate(v = [0,0,10]) cylinder(h = 3, r = (10/sqrt(3)), $fn=6, center=true);
        translate(v = [0,0,-10]) cylinder(h = 5, r = (10/sqrt(3)), center=true);
      }
    }
    translate(v = [0,0,30]) cube([30,6,30], center=true);
    translate(v = [0,0,-0.01])  cylinder(h = 1.01, d1=12, d2=10);
    translate([0,0,10]) cylinder(h = 6, d1=9, d2=6);
    translate([0,0,0.99]) metric_thread (diameter=10, pitch=1, length=12, internal=true, test=debug);
    if (print_SLA) for(i=[0:360/3:360]) rotate([0,0,i]) rotate([90,0,0]) scale([1,1.5,1])  cylinder(h = 40, d=1.5, center=true);
  }

//if (debug) translate(v = [0,0,25]) rotate([90,0,0]) #cylinder(d=16, h=5, center=true);
//cube([B,70,70], center=true);
}