mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 06:08:31 +01:00
add storage_box
This commit is contained in:
parent
bcee313c0e
commit
8eba081532
114
examples/storage_box.scad
Normal file
114
examples/storage_box.scad
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
use <bezier_curve.scad>
|
||||||
|
use <sweep.scad>
|
||||||
|
use <matrix/m_transpose.scad>
|
||||||
|
use <util/sum.scad>
|
||||||
|
|
||||||
|
size = [100, 50, 120];
|
||||||
|
panel_thickness = 1.5;
|
||||||
|
draw_thickness = 1.25;
|
||||||
|
drawer_numbers = 3;
|
||||||
|
spacing = 0.6;
|
||||||
|
|
||||||
|
storage_box(size, panel_thickness, draw_thickness, drawer_numbers, spacing);
|
||||||
|
|
||||||
|
module storage_box(size, panel_thickness, draw_thickness, drawer_numbers, spacing) {
|
||||||
|
p0 = [size.x * 0.5, size.y * 0.5, 0];
|
||||||
|
p1 = [size.x * 0.75, size.y * 0.5, size.z * 0.25];
|
||||||
|
p2 = [size.x * 0.5, size.y * 0.5, size.z * 0.5];
|
||||||
|
p3 = [size.x * 0.25, size.y * 0.5, size.z * 0.75];
|
||||||
|
p4 = [size.x * 0.5, size.y * 0.5, size.z];
|
||||||
|
|
||||||
|
control_points = [p0, p1, p2, p3, p4];
|
||||||
|
|
||||||
|
t_step = 1 / (drawer_numbers * 10 + 2);
|
||||||
|
|
||||||
|
path1 = bezier_curve(t_step, control_points);
|
||||||
|
path2 = bezier_curve(t_step, [for(p = control_points) p - [size.x, 0, 0]]);
|
||||||
|
path3 = bezier_curve(t_step, [for(p = control_points) p - [size.x, size.y, 0]]);
|
||||||
|
path4 = bezier_curve(t_step, [for(p = control_points) p - [0, size.y, 0]]);
|
||||||
|
|
||||||
|
path_leng = len(path1);
|
||||||
|
|
||||||
|
step = floor((path_leng - 2) / drawer_numbers);
|
||||||
|
|
||||||
|
drawer_profiles = [
|
||||||
|
for(i = [0:drawer_numbers - 1])
|
||||||
|
let(start = i * step + 1)
|
||||||
|
concat(
|
||||||
|
[
|
||||||
|
for(j = [start:start+step])
|
||||||
|
let(p = path1[j])
|
||||||
|
[p.x, p.z]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
for(j = start+step; j >= start; j = j - 1)
|
||||||
|
let(p = path2[j])
|
||||||
|
[p.x, p.z]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
drawer_profiles2 = [
|
||||||
|
for(i = [0:drawer_numbers - 1])
|
||||||
|
let(start = i * step + 1)
|
||||||
|
concat(
|
||||||
|
[
|
||||||
|
for(j = [start:start+step + 1])
|
||||||
|
let(p = path1[j])
|
||||||
|
[p.x, p.z]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
for(j = start+step + 1; j >= start; j = j - 1)
|
||||||
|
let(p = path2[j])
|
||||||
|
[p.x, p.z]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
color("white")
|
||||||
|
difference() {
|
||||||
|
sweep(m_transpose([path4, path3, path2, path1]));
|
||||||
|
|
||||||
|
translate([0, size.y * 0.5 - panel_thickness, 0])
|
||||||
|
rotate([90, 0, 0])
|
||||||
|
linear_extrude(size.y)
|
||||||
|
for(profile = drawer_profiles) {
|
||||||
|
offset(-panel_thickness)
|
||||||
|
polygon(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
translate([0, size.y * 0.5 - panel_thickness - spacing * 0.5, 0])
|
||||||
|
rotate([90, 0, 0])
|
||||||
|
for(i = [0:drawer_numbers - 1]) {
|
||||||
|
translate([0, 0, size.y * 0.9 - size.y / drawer_numbers * i]) {
|
||||||
|
color(rands(0, 1, 3))
|
||||||
|
difference() {
|
||||||
|
linear_extrude(size.y - panel_thickness - spacing * 0.5)
|
||||||
|
offset(-panel_thickness - spacing * 0.5)
|
||||||
|
polygon(drawer_profiles[i]);
|
||||||
|
|
||||||
|
translate([0, 0, draw_thickness])
|
||||||
|
linear_extrude(size.y - panel_thickness - draw_thickness * 2)
|
||||||
|
offset(-panel_thickness - spacing * 0.5 - draw_thickness)
|
||||||
|
polygon(drawer_profiles2[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
color(rands(0, 1, 3))
|
||||||
|
translate([0, 0, size.y - draw_thickness * 2])
|
||||||
|
translate(sum(drawer_profiles[i]) / len(drawer_profiles[i]))
|
||||||
|
difference() {
|
||||||
|
linear_extrude(draw_thickness * 4)
|
||||||
|
offset(1)
|
||||||
|
text("~",
|
||||||
|
font = "Arial Black",
|
||||||
|
size = size.z / drawer_numbers / 2,
|
||||||
|
valign = "center",
|
||||||
|
halign = "center"
|
||||||
|
);
|
||||||
|
linear_extrude(draw_thickness * 3)
|
||||||
|
square([size.z / 10, size.z / 5], center = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user