3d_print/Dom/tabl_basi_dzien.scad
2025-12-15 23:42:49 +01:00

84 lines
No EOL
2.7 KiB
OpenSCAD

include <BOSL2/std.scad>
day = ["P","W","Ś","C","P","S","N"];
layer_h = 0.3;
hole_w = 13;
hole_d = 13;
hole_h = 8;
t_w = 3;
t_d = 6;
num_w = 1;
num_d = 2;
t = 2;
r = 1;
cap_t = 2;
$slop=0.35;
conn_l = 20;
conn_w = 8;
// constants for easy modeling
box_w = hole_w*num_w + t_w*(num_w+1);
box_d = hole_d*num_d + t_d*(num_d-1) + 2*t;
box_h = hole_h+t;
conn_cyl1 = [hole_d/2 + t,hole_d/2+t_d+hole_d+t];
conn_cyl2 = [hole_d/2+t_d - t,hole_d/2+t_d+hole_d+conn_l+t_d/2+t - r];
difference() {
// main box
cuboid([box_w,box_d,box_h], rounding=r);
// holes
left((hole_w+t_w) * (num_w-1)/2) back((hole_d+t_d) * (num_d-1)/2)
for(i=[0:num_w-1]) { for(j=[0:num_d-1]) {
right(i*(hole_w + t_w)) fwd(j*(hole_d + t_d)) up(t/2) union() {
cuboid([hole_w, hole_d, hole_h], chamfer=-0.5, edges=TOP);
// channel for locking mechanism
up(hole_h/2 - cap_t/2 - 0.2) cuboid([hole_w+$slop, hole_d+$slop, layer_h*3], chamfer=layer_h/2);
}
}}
}
// connecting tabs / hinges
down(box_h/2 - layer_h/2) back(box_d/2 + conn_l/2)
left((hole_w+t_w) * (num_w-1)/2) for(i = [0 : num_w-1]) {
right(i*(hole_w + t_w)) cuboid([conn_w,conn_l + 2*r,layer_h]);
}
// cap
back(box_d/2 + conn_l - t) down(box_h/2)
left((hole_w+t_w) * (num_w-1)/2) back(hole_d)
for(i=[0:num_w-1]) { for(j=[0:num_d-1]) {
right(i*(hole_w + t_w)) back(j*(hole_d + t_d)) difference() {
union() {
// cap body
cuboid([hole_w-$slop, hole_d-$slop, cap_t + t], anchor=BOTTOM, chamfer=0.5, edges=TOP);
// cap thicker part to friction lock
up(cap_t + t - 0.8) cuboid([hole_w, hole_d, layer_h*1.5], rounding=layer_h/2);
// cap top with letters
cuboid([hole_w+t, hole_d+t, t], anchor=BOTTOM, rounding=1, edges="Z");
fwd(hole_d/2) cuboid([conn_w, t_d - t/2, layer_h], anchor=BOTTOM+BACK);
if(j==(num_d-1)) {
// round tab to open the container
back(hole_d/2) cyl(d=hole_w, h=t, anchor=BOTTOM, chamfer=0.5);
// chamfers for connectors
for(k = conn_cyl1) {
up(t/2 + layer_h) fwd(k) difference() {
cuboid([conn_w,t,t]);
up(t/2) fwd(t/2) xrot(45) cuboid([conn_w+1,t*2,t*2]);
}
}
for(k = conn_cyl2) {
up(t/2 + layer_h) fwd(k) difference() {
cuboid([conn_w,t,t]);
up(t/2) back(t/2) xrot(45) cuboid([conn_w+1,t*2,t*2]);
}
}
}
}
text3d(day[i], center=true, orient=BOTTOM, spin=180, h=layer_h*2, size=8);
}
}
}