sirens/designs/openscad/tests/box.scad
Michael Winter 0fbf33b756 Restructure project with OpenSCAD redesign and v1 legacy code
- Move legacy FreeCAD files to v1/
- Add OpenSCAD programmatic CAD designs
- Add README and AGENTS.md documentation
- Add .gitignore
- Update firmware to v2 architecture
2026-03-29 14:24:42 +02:00

167 lines
4.9 KiB
OpenSCAD

include <Round-Anything-master/polyround.scad>
$fn = $preview ? 32 : 64;
module rounded_rectangle(width, length, height, radius1, radius2) {
polyRoundExtrude([
[-width/2, -length/2, 1], // Bottom-left point
[-width/2, length/2, 1], // Top-left point
[width/2, length/2, 1], // Top-right point
[width/2, -length/2, 1] // Bottom-right point
], height, radius1, radius2);
}
module box() {
difference() {
// Outer rounded box
minkowski() {
cube([width + wall_thickness*2 + inset_distance*2,
depth + wall_thickness*2 + inset_distance*2,
height + wall_thickness*2 + inset_distance*2], center = true);
sphere(r = radius);
}
// Inner space (centered)
minkowski() {
cube([width + inset_distance*2,
depth + inset_distance*2,
height + inset_distance*2], center = true);
sphere(r = radius);
}
/*cube([width,
depth,
height], center = true);
*/
translate([0, 0, height/2 + radius + wall_thickness + inset_distance])
inset(width = width, height = depth);
rotate([180, 0, 0])
translate([0, 0, height/2 + radius + wall_thickness + inset_distance])
inset(width = width, height = depth);
rotate([90, 0, 0])
translate([0, 0, depth/2 + radius + wall_thickness + inset_distance])
inset(width = width, height = height);
rotate([-90, 0, 0])
translate([0, 0, depth/2 + radius + wall_thickness + inset_distance])
inset(width = width, height = height );
rotate([0, 90, 0])
translate([0, 0, width/2 + radius + wall_thickness + inset_distance])
inset(width = height, height = depth);
rotate([0, -90, 0])
translate([0, 0, width/2 + radius + wall_thickness + inset_distance])
inset(width = height, height = depth);
translate([0, 0, (height + inset_distance*2) / 2 + 1])
minkowski() {
cube([width + wall_thickness*2 + inset_distance*2 + 10, 4, 1], center = true);
sphere(r = 0.5);
}
}
}
module inset(width, height) {
translate([0, 0, -inset_inner_thickness - inset_outer_thickness])
linear_extrude(height = inset_inner_thickness) {
minkowski() {
square([
width - (2 * hole_inset_distance),
height - (2 * hole_inset_distance)
], center = true);
circle(r = radius);
}
}
translate([0, 0, -inset_outer_thickness])
linear_extrude(height = inset_outer_thickness) {
minkowski() {
square([width, height], center = true);
circle(r = radius);
}
}
}
module rounded_inset(width, height) {
/*(translate([0, 0, -inset_inner_thickness - inset_outer_thickness])
linear_extrude(height = inset_inner_thickness) {
minkowski() {
square([
width - (2 * hole_inset_distance),
height - (2 * hole_inset_distance)
], center = true);
circle(r = radius);
}
}*/
translate([0, 0, -inset_inner_thickness*2 - inset_outer_thickness])
rounded_rectangle(
width - (2 * hole_inset_distance),
height - (2 * hole_inset_distance),
inset_inner_thickness*2, -2, -2);
translate([0, 0, -inset_outer_thickness])
linear_extrude(height = inset_outer_thickness) {
minkowski() {
square([width, height], center = true);
circle(r = radius);
}
}
}
module snap(){
}
module half_box() {
difference(){
intersection(){
box();
translate([0, 0, (height + wall_thickness*2 + radius*2 + inset_distance*2) / 2])
cube([width + wall_thickness*2 + radius*2 + inset_distance*2,
depth + wall_thickness*2 + radius*2 + inset_distance*2,
height + wall_thickness*2 + radius*2 + inset_distance*2], center = true);
}
/*
minkowski() {
cube([width+ inset_inner_thickness*2,
depth+ inset_inner_thickness*2,
3], center = true);
sphere(r = radius);
}
*/
}
}
// Example usage
width = 110; // Total width
height = 40; // Total height
depth = 110; // Total depth
radius = 3; // Box corner radius
wall_thickness = 3; // Wall thickness
inset_distance = 4; //distance from inset side
hole_inset_distance = 2; //distance from inset side
hole_radius = 3; // Hole corner radius
inset_inner_thickness = 1.7;
inset_outer_thickness = 1.5;
//
half_box();
//rounded_inset(width, height);