eurobox.scad 3.66 KB
include<vars.scad>
include<modules.scad>

module handleShape(x,y,z,extra,bool){
  translate([
             x/2 - handleWidth/2 - offset,
             -( offset+1 ),
             z-(2.06+roundborderInner+strength*3)
             ]) {
    hull() {
      translate([-extra,0,-1])cube([handleWidth+extra*2,5,1]);
      translate([handleCorner,0,handleCorner-handleHeight]) rotate([-90,0,0]) union() {
        cylinder(r=handleCorner+extra,h=5);
        translate([handleWidth-handleCorner*2,0,0]) cylinder(r=handleCorner+extra,h=5);
      }
    }
    if(bool==true) {
      hull() {
        translate([-strength*2,0,-1.5])
          cube([handleWidth+strength*4,1,1]);
        translate([-strength*2,0.85,-(1+handleHeight+strength)])
          cube([handleWidth+strength*4,1,1]);
      }
    }
  }
}


module volume(x,y,z,extra) {
  hull() {minkowski() {
      translate([strength*1.5,strength*1.5,0]) cube([
                                                     x-(offset)*2-strength*3,
                                                     y-(offset)*2-strength*3,
                                                     1
                                                     ]);
      sphere(r=roundborderInner+extra);
    }
    minkowski() {
      translate([0,0,z]) cube([
                               x-(offset)*2,
                               y-(offset)*2,
                               1
                               ]);
      sphere(r=roundborderInner+extra);
    }
  }
}

module innerWall(x,y,z) {
  difference() {
    volume(x,y,z,strength);
    volume(x,y,z,0);
  }
}
module grateX(x,y,z) {
  translate([0,8,0]) cube([x/2,strength,z]);
}

module grateY(x,y,z) {
  translate([7,0,0]) cube([strength,y/2,z]);
}

module grateXY(x,y,z) {
  translate([0,0+strength/2,0]) {
    rotate([0,0,-45])
      cube([strength,y/2,z]);
  }
}

module grateZ(x,y,z) {
  translate([-(offset),-(offset),z])
    cube([x,y,strength]);
}

module grates(x,y,z) {
  translate([ -offset,
              -offset,
              base ]) {
    union() {
      grateX(x,y,z);
      grateY(x,y,z);
      grateXY(x,y,z);
    }
  }
}

module mirroredgrates(x,y,z) {
  union() {
    union() {
      grates(x,y,z);
      translate([-offset*2+x,0, 0]) mirror([1,0,0]) grates(x,y,z);
    }
    translate([0,-offset*2+y, 0]) mirror([0,1,0]) {
      union() {
        grates(x,y,z);
        translate([-offset*2+x,0, 0]) mirror([1,0,0]) grates(x,y,z);
      }
    }
  }
}

module eurobox(x,y,z,handle) {
  color("#888") translate([offset, offset, roundborderInner+strength]) {
    difference () {
      union() {
        intersection() {
          union() {
            innerWall(x,y,z);
            mirroredgrates(x,y,z);
            grateZ(x,y,base);
            grateZ(x,y,z-(roundborderInner+strength*2));
            grateZ(x,y,z-(2.06+roundborderInner+strength*3));
            if (handle==true) {
              handleShape(x,y,z,strength,bool=false);
              translate([0,y-4,0])mirror([0,1,0]){
                handleShape(x,y,z,strength,bool=false);
              }
            }
          }
          intersection() {
            shapeZ(x,y,z);
            translate([-offset,-offset,-(roundborderInner+strength)]) cube([x,y,z]);
          }
        }
      }
      union() {
        volume(x,y,z,0);
        if (handle==true) {
          handleShape(x,y,z,0,bool=true);
          translate([0,y-offset*2,0])mirror([0,1,0]){
            handleShape(x,y,z,0,bool=true);
          }
        }
      }
    }
  }
}

/* eurobox(30,40,22,true);  */

/* testprobes */

/* translate([0,18,0]) #cube([1.9,2,3]); */
/* translate([0,18,18]) #cube([1.5,2,3]); */
/* difference(){ */
/* eurobox(30,40,22,true); */
/*   translate([-1,-1,-10]) cube([15,20,30]); */
/* } */