bakje/koffer.scad
2023-02-24 15:53:09 +01:00

236 lines
6.0 KiB
OpenSCAD

/*[bakje famili]*/
CHAMFER = 5.0; // mm
UNIT = 50.0; // mm
HIEGHT = 1.0; // units
/*[andere dingen]*/
INNER_TOLLERANCE = 0.0; // [0.0:0.05:0.5]
MATT_THIKNESS = 10.0; // [2.0:0.1:15.0]
WIDTH = 7; // [1:1:10]
DEPTH = 5; // [1:1:10]
DIMENTION = "2d"; // [2d: 2d export view, 3d: 3d render]
POSITION = "inplace"; // [inplace: in place, origin: at the origin]
RENDER = "all"; // [bot: bottom, lid: lid, front: front, back: back, left: left, right: right, all: all]
LAYOUT_SEPERATION = 15; // [1:1:50]
function finger(flip=[1,0], dir="y") = [
[
0, 0
],[
(dir=="y") ? 0 : flip[0]*0.25*UNIT,
(dir=="x") ? 0 : flip[1]*0.25*UNIT,
],[
(dir=="y") ? flip[0]*MATT_THIKNESS : flip[0]*0.25*UNIT,
(dir=="x") ? flip[1]*MATT_THIKNESS : flip[1]*0.25*UNIT,
],[
(dir=="y") ? flip[0]*MATT_THIKNESS : flip[0]*0.75*UNIT,
(dir=="x") ? flip[1]*MATT_THIKNESS : flip[1]*0.75*UNIT,
],[
(dir=="y") ? 0 : flip[0]*0.75*UNIT,
(dir=="x") ? 0 : flip[1]*0.75*UNIT,
],[
(dir=="y") ? 0 : flip[0]*UNIT,
(dir=="x") ? 0 : flip[1]*UNIT,
],
];
module fingers(flip=[1,1], dir="y", number=2, nub=true){
flipG = [
(nub || dir == "x") ? flip[0] : -flip[0],
(nub || dir == "y") ? flip[1] : -flip[1]
];
for (f = [0:1:number-1])
translate([
(dir=="x") ? f*UNIT : ((nub) ? 0 : flip[0]*MATT_THIKNESS),
(dir=="y") ? f*UNIT : ((nub) ? 0 : flip[1]*MATT_THIKNESS)
])
polygon(
points = concat(
finger(flip=flipG, dir=dir),
[
[
(dir=="y") ? flip[0]*((nub) ? -0.01 : -MATT_THIKNESS - 0.01) : flip[0]*UNIT,
(dir=="x") ? flip[1]*((nub) ? -0.01 : -MATT_THIKNESS - 0.01) : flip[1]*UNIT
],[
(dir=="y") ? flip[0]*((nub) ? -0.01 : -MATT_THIKNESS - 0.01) : 0,
(dir=="x") ? flip[1]*((nub) ? -0.01 : -MATT_THIKNESS - 0.01) : 0
]
]
)
);
}
module render(3dPos, 3dRotation, 2dPos){
if (DIMENTION == "2d"){
if (POSITION == "inplace")
translate(2dPos)
children();
if (POSITION == "origin")
children();
}
if (DIMENTION == "3d"){
if (POSITION == "inplace")
translate(3dPos)
rotate(3dRotation)
linear_extrude(MATT_THIKNESS)
children();
if (POSITION == "origin")
linear_extrude(MATT_THIKNESS)
children();
}
}
if (RENDER == "bot" || RENDER == "all")
render(
2dPos = [0, 0],
3dPos = [0, 0, 0],
3dRotation = [0, 0, 0]
)
bottom();
if (RENDER == "front" || RENDER == "all")
render(
2dPos = [-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION), 0],
3dPos = [0, MATT_THIKNESS, 0],
3dRotation = [90, 0, 0]
)
front();
if (RENDER == "back" || RENDER == "all")
render(
2dPos = [
-(WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION),
HIEGHT*UNIT + MATT_THIKNESS + LAYOUT_SEPERATION
],
3dPos = [0, DEPTH*UNIT + 2*MATT_THIKNESS, 0],
3dRotation = [90, 0, 0]
)
back();
if (RENDER == "left" || RENDER == "all")
render(
2dPos = [
-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION),
2*HIEGHT*UNIT + 2*MATT_THIKNESS + 2*LAYOUT_SEPERATION
],
3dPos = [0, 0, 0],
3dRotation = [90, 0, 90]
)
side();
if (RENDER == "right" || RENDER == "all")
render(
2dPos = [
-(DEPTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION),
3*HIEGHT*UNIT + 4*MATT_THIKNESS + 3*LAYOUT_SEPERATION
],
3dPos = [WIDTH*UNIT + MATT_THIKNESS, 0, 0],
3dRotation = [90, 0, 90]
)
side();
if (RENDER == "lid" || RENDER == "all")
render(
2dPos = [
WIDTH*UNIT + 2*MATT_THIKNESS + LAYOUT_SEPERATION,
0
],
3dPos = [MATT_THIKNESS, 0, HIEGHT*UNIT + MATT_THIKNESS],
3dRotation = [90, 0, 90]
)
lid();
// if (RENDER == "lid" || RENDER == "all"){
// if (DIMENTION == "2d"){
// lid();
// }
// if (DIMENTION == "3d"){
// if (POSITION == "inplace")
// translate([MATT_THIKNESS, 0, HIEGHT*UNIT + MATT_THIKNESS])
// linear_extrude(MATT_THIKNESS)
// lid();
// if (POSITION == "origin")
// linear_extrude(MATT_THIKNESS)
// lid();
// }
// }
module bottom(){
translate([MATT_THIKNESS, MATT_THIKNESS])
union(){
translate([0.005, 0.005])
square(size=[WIDTH*UNIT-0.01, DEPTH*UNIT-0.01]);
fingers(flip=[-1,1], dir="y", number=DEPTH, nub=true);
translate([WIDTH*UNIT, 0])
fingers(flip=[1,1], dir="y", number=DEPTH, nub=true);
fingers(flip=[1,-1], dir="x", number=WIDTH, nub=true);
translate([0, DEPTH*UNIT])
fingers(flip=[1,1], dir="x", number=WIDTH, nub=true);
}
}
module front(){
translate([MATT_THIKNESS, MATT_THIKNESS])
difference(){
union(){
translate([0.005, 0.005])
square(size=[WIDTH*UNIT-0.01, HIEGHT*UNIT-0.005]);
fingers(flip=[-1,1], dir="y", number=HIEGHT, nub=true);
translate([WIDTH*UNIT, 0])
fingers(flip=[1,1], dir="y", number=HIEGHT, nub=true);
fingers(flip=[1,-1], dir="x", number=WIDTH, nub=false);
}
translate([52, HIEGHT*UNIT-10])
circle(d=3);
translate([77, HIEGHT*UNIT-10])
circle(d=3);
translate([WIDTH*UNIT-52, HIEGHT*UNIT-10])
circle(d=3);
translate([WIDTH*UNIT-77, HIEGHT*UNIT-10])
circle(d=3);
}
}
module back(){
translate([MATT_THIKNESS, MATT_THIKNESS])
union(){
translate([0.005, 0.005])
square(size=[WIDTH*UNIT-0.01, HIEGHT*UNIT-0.005]);
fingers(flip=[-1,1], dir="y", number=HIEGHT, nub=true);
translate([WIDTH*UNIT, 0])
fingers(flip=[1,1], dir="y", number=HIEGHT, nub=true);
fingers(flip=[1,-1], dir="x", number=WIDTH, nub=false);
}
}
module side(){
translate([MATT_THIKNESS, MATT_THIKNESS])
union(){
translate([0.005, 0.005])
square(size=[DEPTH*UNIT-0.01, HIEGHT*UNIT-0.005 + MATT_THIKNESS]);
translate([-MATT_THIKNESS, -MATT_THIKNESS])
square(size=[MATT_THIKNESS+0.01, MATT_THIKNESS+0.01]);
translate([DEPTH*UNIT-0.01, -MATT_THIKNESS])
square(size=[MATT_THIKNESS+0.01, MATT_THIKNESS+0.01]);
translate([-MATT_THIKNESS, HIEGHT*UNIT-0.01])
square(size=[MATT_THIKNESS+0.01, MATT_THIKNESS+0.01]);
translate([DEPTH*UNIT-0.01, HIEGHT*UNIT-0.01])
square(size=[MATT_THIKNESS+0.01, MATT_THIKNESS+0.01]);
fingers(flip=[-1,1], dir="y", number=HIEGHT, nub=false);
translate([DEPTH*UNIT, 0])
fingers(flip=[1,1], dir="y", number=HIEGHT, nub=false);
fingers(flip=[1,-1], dir="x", number=DEPTH, nub=false);
}
}
module lid(){
square([WIDTH*UNIT, DEPTH*UNIT + 2*MATT_THIKNESS]);
}