2024-10-15 17:11:06 +00:00
|
|
|
|
|
|
|
module hexagon(r, h) {
|
2024-11-07 22:32:52 +00:00
|
|
|
cylinder(r = r, h = h, center = 2, $fn = 6);
|
2024-10-15 17:11:06 +00:00
|
|
|
}
|
|
|
|
|
2024-09-17 01:35:12 +00:00
|
|
|
module pill(length, bevel) {
|
|
|
|
hull() {
|
|
|
|
translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel);
|
|
|
|
translate([0, 0, (length / 2) - bevel]) sphere(r = bevel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-07 22:32:52 +00:00
|
|
|
module rounded_cube(dimensions, bevel = 0) {
|
|
|
|
x = dimensions[0];
|
|
|
|
y = dimensions[1];
|
|
|
|
z = dimensions[2];
|
|
|
|
|
|
|
|
if (bevel > 0) {
|
|
|
|
hull() {
|
|
|
|
translate([-x / 2 + bevel, -y / 2 + bevel, -z / 2 + bevel]) sphere(r = bevel);
|
|
|
|
translate([ x / 2 - bevel, -y / 2 + bevel, -z / 2 + bevel]) sphere(r = bevel);
|
|
|
|
translate([ x / 2 - bevel, y / 2 - bevel, -z / 2 + bevel]) sphere(r = bevel);
|
|
|
|
translate([-x / 2 + bevel, y / 2 - bevel, -z / 2 + bevel]) sphere(r = bevel);
|
|
|
|
translate([-x / 2 + bevel, -y / 2 + bevel, z / 2 - bevel]) sphere(r = bevel);
|
|
|
|
translate([ x / 2 - bevel, -y / 2 + bevel, z / 2 - bevel]) sphere(r = bevel);
|
|
|
|
translate([ x / 2 - bevel, y / 2 - bevel, z / 2 - bevel]) sphere(r = bevel);
|
|
|
|
translate([-x / 2 + bevel, y / 2 - bevel, z / 2 - bevel]) sphere(r = bevel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cube(dimensions, center = true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:30 +00:00
|
|
|
module box_face(dimensions, bevel = 0) {
|
|
|
|
x = dimensions[0];
|
|
|
|
y = dimensions[1];
|
|
|
|
z = dimensions[2];
|
|
|
|
|
|
|
|
if (bevel > 0) {
|
|
|
|
translate([0, 0, z / 2])
|
|
|
|
hull() {
|
|
|
|
pill(z, bevel);
|
|
|
|
translate([x, 0, 0])
|
|
|
|
pill(z, bevel);
|
|
|
|
translate([x, y, 0])
|
|
|
|
pill(z, bevel);
|
|
|
|
translate([0, y, 0])
|
|
|
|
pill(z, bevel);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cube(dimensions);
|
2024-09-17 01:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:30 +00:00
|
|
|
module channel(length, width, height, bevel) {
|
2024-09-17 01:35:12 +00:00
|
|
|
union() {
|
2024-09-27 02:15:30 +00:00
|
|
|
box_face([length, width, wall_thickness], bevel);
|
|
|
|
|
|
|
|
translate([0, wall_thickness - bevel, bevel])
|
|
|
|
rotate([90, 0, 0])
|
|
|
|
box_face([length, height, wall_thickness], bevel);
|
|
|
|
|
|
|
|
translate([0, width + bevel, bevel])
|
|
|
|
rotate([90, 0, 0])
|
|
|
|
box_face([length, height, wall_thickness], bevel);
|
2024-09-17 01:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:30 +00:00
|
|
|
module box(length, width, height, bevel = 0) {
|
2024-09-17 01:35:12 +00:00
|
|
|
union() {
|
2024-09-27 02:15:30 +00:00
|
|
|
channel(length, width, height, bevel);
|
|
|
|
|
|
|
|
translate([-bevel, 0, bevel])
|
|
|
|
rotate([90, 0, 0])
|
|
|
|
rotate([0, 90, 0])
|
|
|
|
box_face([width, height, wall_thickness], bevel);
|
2024-10-15 13:41:52 +00:00
|
|
|
|
2024-09-27 02:15:30 +00:00
|
|
|
translate([length - wall_thickness + bevel, 0, bevel])
|
|
|
|
rotate([90, 0, 0])
|
|
|
|
rotate([0, 90, 0])
|
|
|
|
box_face([width, height, wall_thickness], bevel);
|
2024-09-17 01:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-15 13:41:52 +00:00
|
|
|
module box_side_slider(length, width, height) {
|
|
|
|
difference() {
|
|
|
|
box_face([width - wall_thickness * 2 + 4, height, wall_thickness], bevel);
|
|
|
|
translate([-1, -1, 1]) cube([4-threshold, height+2, 4-threshold]);
|
|
|
|
color("red") translate([width - wall_thickness * 2 + 1, -1, 1]) cube([4-threshold, height+2, 4-threshold]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|