bakje/bakje_base.scad

181 lines
4.1 KiB
OpenSCAD

/*[bakje famili]*/
CHAMFER = 5.0; // mm
UNIT = 50.0; // mm
HIEGHT = 1.0; // units
/*[andere dingen]*/
OUTER_TOLLERANCE = 0.2; // [0.05:0.05:0.5]
WALL_THIKNESS = 1.2; // [0.5:0.1:5]
// WIDTH = 1; // [1:1:10]
// DEPTH = 1; // [1:1:10]
// LABLE_HIEGHT = 10.0; // [1.0:0.125:20.0]
// //LABLE_WIDTH = floor(0.25*WIDTH) + 0.8; // [0.1:0.1:3.0]
// LABLE_WIDTH = max(0.08, 0.9 - 0.1*WIDTH) * WIDTH; // [0.1:0.1:3.0]
module grid(width=1, depth=1){
intersection(){
union(){
for (x = [ -(width)/2 : 1.0 : (width)/2 ]){
translate([x*UNIT, 0, 0])
rotate([0, 45, 0])
cube([
CHAMFER*sqrt(2),
UNIT*depth,
CHAMFER*sqrt(2)
], center=true);
}
for (y = [ -(depth)/2 : 1.0 : (depth)/2 ]){
translate([0, y*UNIT, 0])
rotate([45, 0, 0])
cube([
UNIT*width,
CHAMFER*sqrt(2),
CHAMFER*sqrt(2)
], center=true);
}
}
translate([0, 0, 5*CHAMFER])
cube([
UNIT*width - 2*OUTER_TOLLERANCE,
UNIT*depth - 2*OUTER_TOLLERANCE,
10*CHAMFER
], center=true);
}
}
module bakje(width=1, depth=1){
difference(){
union(){
for (x = [-(width-1)/2:1.0:(width-1)/2])
for (y = [-(depth-1)/2:1.0:(depth-1)/2]){
translate([
x*UNIT,
y*UNIT,
0
])
floor();
}
walls(width=width, depth=depth, cut=false);
}
walls(width=width, depth=depth, cut=true);
}
}
module bakje_cut(width=1, depth=1){
walls(width=width, depth=depth, cut=true);
translate([0, 0, 100+UNIT*HIEGHT])
cube([width*2*UNIT, depth*2*UNIT, 200], center=true);
translate([0, 0, -100])
cube([width*2*UNIT, depth*2*UNIT, 200], center=true);
grid(width=width, depth=depth);
}
module walls(width=1, depth=1, cut=false){
union(){
thinkness = (cut ? 50 : 1) * WALL_THIKNESS;
for (side = [-1,1])
translate([
0,
side*(0.5*UNIT*depth - ((cut) ? -0.5 : 0.5)*thinkness - OUTER_TOLLERANCE),
0.5*UNIT*HIEGHT + (cut ? 0 : 0.5*CHAMFER)
])
{
cube([
UNIT*width - 2*CHAMFER - 2*OUTER_TOLLERANCE,
(cut ? 1.0 : 1.001) * thinkness,
UNIT*HIEGHT - (cut ? -CHAMFER : CHAMFER)
], center=true);
for (edge = [-1,1])
translate([
edge*(0.5*UNIT*width - 0.5*CHAMFER),
-side*(0.5*CHAMFER - (cut ? -0.5 : 0.5)*thinkness),
(cut ? 0 : -0.5*CHAMFER)
])
intersection(){
translate([
edge*(-OUTER_TOLLERANCE - (cut ? -0.5 : 0.5) * thinkness/sqrt(2)),
-side*((cut ? -0.5 : 0.5) * thinkness/sqrt(2)),
0
])
rotate([0, 0, side*edge*-45])
cube([
((cut) ? 15 : 1) * CHAMFER * sqrt(2),
(cut ? 1 : 1.001) * thinkness,
UNIT*HIEGHT + (cut ? 0.5*CHAMFER : 0)
], center=true);
if(!cut)
translate([
-edge*0.5*CHAMFER,
-side*(0.5*CHAMFER - OUTER_TOLLERANCE),
CHAMFER - 0.5*UNIT*HIEGHT])
union(){
translate([0, 0, 0.5*UNIT])
cube([2*CHAMFER, 2*CHAMFER, UNIT*HIEGHT], center=true);
intersection(){
rotate([45, 0, 0])
cube([UNIT*HIEGHT, CHAMFER*sqrt(2), CHAMFER*sqrt(2)], center=true);
rotate([0, 45, 0])
cube([CHAMFER*sqrt(2), UNIT*HIEGHT, CHAMFER*sqrt(2)], center=true);
}
}
}
}
for (side = [-1,1])
translate([
side*(0.5*UNIT*width - ((cut) ? -0.5 : 0.5)*thinkness - OUTER_TOLLERANCE),
0,
0.5*UNIT*HIEGHT + (cut ? 0 : 0.5*CHAMFER)
])
cube([
(cut ? 1 : 1.001) * thinkness,
UNIT*depth - 2*CHAMFER - 2*OUTER_TOLLERANCE,
UNIT*HIEGHT - (cut ? -CHAMFER : CHAMFER)
], center=true);
}
}
module floor() {
module chamfer(cut=false){
thinkness = (cut) ? 5.0 : WALL_THIKNESS;
translate([
0,
0.5*UNIT - 0.5*CHAMFER,
0.5*CHAMFER + WALL_THIKNESS/sqrt(2)
])
rotate([45, 0, 0])
translate([
0,
0,
(cut) ? -0.5*(WALL_THIKNESS+thinkness) + 0.001 : 0,
])
cube([
UNIT,
CHAMFER * sqrt(2) + WALL_THIKNESS - 0.001,
thinkness
], center=true);
}
union(){
translate([0, 0, 0.5*WALL_THIKNESS])
cube([
UNIT - 2*CHAMFER,
UNIT - 2*CHAMFER,
WALL_THIKNESS
], center=true);
difference(){
union(){
for (d = [0:90:360])
rotate([0, 0, d])
chamfer();
}
for (d = [0:90:360])
rotate([0, 0, d])
chamfer(true);
}
}
}