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

include<cuts.scad>
include<screws.scad>
include<pipes.scad>
include<handles.scad>


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,handlecaps,pipes,drilled,screws,locked,exploded) {
  if ( handlecaps ) color("#5fe") handles(x,y,z,exploded=exploded ? [0,-5,0]:[0,0,0]);
  if ( screws ) screws(x,y,z, locked=locked, exploded=exploded ? 5:0);
  if ( pipes ) pipes(z, exploded=exploded ? [-5,0,0]:[0,0,0]);

  difference() {
    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);
            }
          }
        }
      }
    }
    if ( drilled ) drills(x,y,z);
  }
}

/* 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]); */
/* } */