screws.scad 2.71 KB

module screw6x50() {
  color("#ccc") translate([0,0,0]) {
    cylinder(d=0.58,h=5, $fn=10);
    translate([0,0,-screwhead]) {
      cylinder(d=1.2,h=screwhead,$fn=6);
    }
  }
}

module nut() {
  color("#aaa") cylinder(d=1.2,h=nutheight,$fn=6);
}

module shim() {
  color("#eee") cylinder(d=shimdiameter,h=shimheight);
}

module shimSpring(locked) {
  if ( locked == 1 ) {
    color("#0f0") cylinder(d=shimdiameter,h=locked+0.5);
  } else {
    color("#f00") cylinder(d=shimdiameter,h=locked+0.5);
  }
}
module removableshimblock() {
  /* shimblockHeight; */
  /* color("#eee") cylinder(d=1.3,h=0.1); */
}


module cornerscrew( z, upside=false ) {

  translate([0,0,0]) screw6x50();
  shim();

  if ( upside == true ) {
    translate([ 0, 0, shimheight + strength ]) { shim();
      /************            GRATE             ************/
      translate([ 0, 0, shimheight ]) { nut();
        translate([ 0, 0, 1.26]) { nut();
          translate([ 0, 0, nutheight]) { shim();
            /************            NEXT BOX             ************/
            translate([ 0, 0, shimheight+2*strength + 0.1 ]) { nut();
              translate([ 0, 0, nutheight]) rotate([0,0,40]) nut();
            }}}}}
  } else {
    /************            NEXT BOX             ************/
    translate([ 0, 0, shimheight +strength*2 + 0.1]) { nut();
      translate([ 0, 0, 1.54 ]) { nut();
        /************            GRATE             ************/
        translate([ 0, 0, strength + nutheight ]) rotate([0,0,23]) {nut();
          translate([ 0, 0, nutheight]) rotate([0,0,20]) nut();
        }}}
  }

}

module hinges(locked) {
  rotation = locked ? 90 : 0;
  translate([0,0,0.1]) cube([1.4,0.07,0.8]);
  rotate([0,90,0]) translate([-0.1,0,0]) cylinder(r=0.04, h=1.4, $fn=7);
  translate([0,0,0.1]) rotate([rotation,0,0])
         translate([0,-0.1,0]) cube([1.4,0.07,0.8]);
  /* } */
}

module cornerscrews(z, exploded, locked) {
  shift = locked ? 0 : 1.5;

  translate([2.4 + shift
             , 0.8
             , z - 2.66 + exploded
             ])
    cornerscrew(z,upside=true);
  translate([0.8
             , 2.4 + shift
             , recess + strength + shimheight - exploded
             ]) rotate([180,0,0])
    cornerscrew(z,upside=false);

  translate([gratesize,gratesize,recess+strength]) {
    translate([1.3,0-exploded,0]) hinges(locked);
    rotate([0,0,90]) translate([2.8,0+exploded,0]) rotate([0,0,180])hinges(locked);
  }
}


module screws(x,y,z, locked, exploded) {
  cornerscrews(22, exploded, locked);
  mirror([0,1,0])  translate([0,-y,0]) cornerscrews(22, exploded, locked);
  mirror([1,0,0])  translate([-x,0,0]) cornerscrews(22, exploded, locked);
  mirror([1,0,0]) translate([-x,y,0]) mirror([0,1,0])  cornerscrews(22, exploded, locked);
}