monorepo/bike-lights/case/common.scad

58 lines
1.5 KiB
OpenSCAD
Raw Normal View History

module pill(length, bevel) {
hull() {
translate([0, 0, (-length / 2) + bevel]) sphere(r = bevel);
translate([0, 0, (length / 2) - bevel]) sphere(r = bevel);
}
}
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-27 02:15:30 +00:00
module channel(length, width, height, bevel) {
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-27 02:15:30 +00:00
module box(length, width, height, bevel = 0) {
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);
translate([length - wall_thickness + bevel, 0, bevel])
rotate([90, 0, 0])
rotate([0, 90, 0])
box_face([width, height, wall_thickness], bevel);
}
}