sirens/designs/openscad/box_snap.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

332 lines
11 KiB
OpenSCAD

include <Round-Anything-master/polyround.scad>
$fn = $preview ? 32 : 128;
module counter_bored_holes(screw_offset){
// Subtract mounting holes for stator
for (i = [0:360/number_of_mounting_holes:360]) {
// Subtract screw hole
rotate([0, 0, i])
translate([screw_offset, 0, -1]) // Adjusted position
cylinder(d = screw_diameter, h = stator_wall_thickness + 2);
// Subtract counterbore
rotate([0, 0, i])
translate([screw_offset, 0, stator_wall_thickness - screw_bore_depth]) // Adjusted position
cylinder(d = screw_bore_diameter, h = stator_wall_thickness);
}
}
module rounded_cube(width, length, height, radius1, radius2) {
polyRoundExtrude([
[-(width + radius*2)/2, -(length + radius*2)/2, radius], // Bottom-left point
[-(width + radius*2)/2, (length + radius*2)/2, radius], // Top-left point
[(width + radius*2)/2, (length + radius*2)/2, radius], // Top-right point
[(width + radius*2)/2, -(length + radius*2)/2, radius] // Bottom-right point
], height + radius*2, radius1, radius2);
}
module box() {
padding = radius*2 + inset_distance*2;
difference() {
translate([0, 0, -(height + padding + wall_thickness*2)/2])
rounded_cube(
width + wall_thickness*2 + inset_distance*2,
depth + wall_thickness*2 + inset_distance*2,
height + wall_thickness*2 + inset_distance*2,
radius, radius);
translate([0, 0, -(height + radius*2 + inset_distance*2)/2])
rounded_cube(
width + inset_distance*2,
depth + inset_distance*2,
height + inset_distance*2,
radius, radius);
cube([width, depth, height], center = true);
translate([0, 0, (height + padding)/2 + inset_offset])
rounded_inset(width = width, height = depth, inset_scale=0, hole = true, cutout = false);
rotate([180, 0, 0])
translate([0, 0, (height + padding)/2 + inset_offset])
rounded_inset(width = width, height = depth, cutout = false);
rotate([90, 90, 0])
translate([0, 0, (depth + padding)/2 + inset_offset])
rounded_inset(width = height, height = width, cutout = false);
rotate([-90, 90, 0])
translate([0, 0, (depth + padding)/2 + inset_offset])
rounded_inset(width = height, height = width, cutout = false);
rotate([0, 90, 0])
translate([0, 0, (width + padding)/2 + inset_offset])
rounded_inset(width = height, height = depth, cutout = false);
rotate([0, -90, 0])
translate([0, 0, (width + padding)/2 + inset_offset])
rounded_inset(width = height, height = depth, cutout = false);
/*
translate([(width + padding)/2 + 1.5, (depth + padding)/2 + 1.5, 0])
rotate([0, 0, 45])
dowel();
rotate([180, 0, 0])
translate([(width + padding)/2 + 1.5, (depth + padding)/2 + 1.5, 0])
rotate([0, 0, 45])
dowel();
rotate([0, 0, 90])
translate([(depth + padding)/2 + 1.5, (width + padding)/2 + 1.5, 0])
rotate([0, 0, 45])
dowel();
rotate([0, 180, 90])
translate([(depth + padding)/2 + 1.5, (width + padding)/2 + 1.5, 0])
rotate([0, 0, 45])
dowel();
*/
translate([(width + padding + 3.5)/2, (depth + padding + 3.5)/2, (height + padding)/2 + wall_thickness])
counter_bored_hole();
rotate([0, 0, 180])
translate([(width + padding + 3.5)/2, (depth + padding + 3.5)/2, (height + padding)/2 + wall_thickness])
counter_bored_hole();
rotate([0, 0, 90])
translate([(depth + padding + 3.5)/2, (width + padding + 3.5)/2, (height + padding)/2 + wall_thickness])
counter_bored_hole();
rotate([0, 0, -90])
translate([(depth + padding + 3.5)/2, (width + padding + 3.5)/2, (height + padding)/2 + wall_thickness])
counter_bored_hole();
}
}
module rounded_inset(width, height, inset_scale=0, hole = false, cutout = true) {
difference(){
union(){
translate([0, 0, inset_thickness/2 - 0.75])
rounded_cube(
width + 0.85 + inset_scale*2,
height * 0.75 + inset_scale*2,
1.5 - radius*2, 0.75, 0.75);
//translate([0, 0, -inset_thickness])
rounded_cube(
width + inset_scale*2,
height + inset_scale*2,
inset_thickness - radius*2 + inset_scale, 0, 2);
translate([0, 0, -2.5 + inset_scale])
rounded_cube(
width - radius*2 + inset_scale*2,
height - radius*2 + inset_scale*2,
2.5 - radius*2 - inset_scale, 0, 0);
}
if(cutout)
translate([0, 0, -2.5 + inset_scale])
rounded_cube(
width - radius*2 + inset_scale*2 - 2,
height - radius*2 + inset_scale*2 - 2,
2.5 - radius*2 - inset_scale, 0, 0);
}
if(hole)
translate([width/2 + 1, 0, -100])
rounded_cube(2, 3, 110, 0, 0);
if(hole)
rotate([0, 0, 180])
translate([width/2 + 1, 0, -100])
rounded_cube(2, 3, 110, 0, 0);
}
module dowel(inset_scale=0){
//cube([3 + inset_scale, 3 + inset_scale, 10 + inset_scale*2], center=true);
translate([0, 0, -6])
rounded_cube(-0.5 + inset_scale*3, -0.5 + inset_scale*3, 8 + inset_scale*3, 1, 1);
}
module counter_bored_hole(){
translate([0, 0, -7])
cylinder(d = screw_bore_diameter, h = 7);
translate([0, 0, -20])
cylinder(d = screw_diameter, h = 20);
translate([0, 0, -20])
cylinder(d = screw_insert_diameter, h = 9);
}
module box_bottom() {
difference(){
intersection(){
box();
translate([0, 0, 40])
cube([width + wall_thickness*2 + radius*4 + inset_distance*2,
depth + wall_thickness*2 + radius*4 + inset_distance*2,
height + wall_thickness*2 + radius*4 + inset_distance*2], center = true);
}
}
}
module box_top() {
difference(){
difference(){
box();
translate([0, 0, 40])
cube([width + wall_thickness*2 + radius*4 + inset_distance*2,
depth + wall_thickness*2 + radius*4 + inset_distance*2,
height + wall_thickness*2 + radius*4 + inset_distance*2], center = true);
}
}
}
module front_face() {
difference(){
union(){
rounded_inset(width = height, height = width, inset_scale=inset_scale_factor, hole = false);
translate([0, 15, -7])
cylinder(d = 18, h = 9.2);
}
translate([0, 15, -5])
cylinder(d = 16, h = 7.2);
translate([0, 15, -7])
cylinder(d = 7.5, h = 7.5);
translate([0, -15, 0])
linear_extrude(2.5){
square([17.5, 25.5], center = true);
}
}
}
module back_face() {
difference(){
rounded_inset(width = height, height = width, inset_scale=inset_scale_factor, hole = false);
translate([0, -30, -10])
cylinder(d = 10, h = 20);
translate([0, 30, -10])
cylinder(d = 10, h = 20);
//rotate([0, 0, 90])
translate([0, width/2 - 27.5, 0])
for (i = [0:1:2]) {
translate([0, -10 * i, -1])
rounded_cube(15, -1, 10, 0, 0);
}
}
}
module bottom_face() {
rounded_inset(width = width, height = depth, inset_scale=inset_scale_factor, hole = false);
}
module bottom_face_alt() {
tab_height = 35;
tab_width = 65;
rail_width = 48.5;
difference(){
union(){
rounded_inset(width = width, height = depth, inset_scale=inset_scale_factor, hole = false);
rotate([180, 0, 0])
translate([0, depth/2 - 20, 0])
rounded_cube(tab_width, -1, tab_height, 2, -2);
rotate([180, 0, 0])
translate([0, depth/2 - depth + 15, 0])
rounded_cube(tab_width - 15, -1, tab_height, 2, -2);
}
translate([0, -10, -tab_height + 3])
cube([rail_width, 20, 3.5], center=true);
translate([0, -10, -tab_height + 3 + 26])
cube([rail_width, 20, 3.5], center=true);
translate([-tab_width + 7 + 10, -10, -tab_height + 3 + 13])
cube([rail_width, 20, 13], center=true);
translate([0, 10, -tab_height + 3 + 17])
cube([35, 20, 13], center=true);
//translate([0, 10, -tab_height + 3])
// cube([35, 20, 6], center=true);
}
}
module top_face() {
difference(){
rounded_inset(width = width, height = depth, inset_scale=inset_scale_factor, hole = false);
rotate([0, 0, 90])
translate([depth/2 - 15, width/2 - 12.5, -5])
for (i = [0:1:5]) {
translate([0, -10 * i, -1])
rounded_cube(15, -1, 10, 0, 0);
}
}
}
module side_face() {
rounded_inset(width = height, height = depth, inset_scale=inset_scale_factor, hole = false);
}
width = 75;//90; // Total width
height = 30; // Total height
depth = 60; //110; // Total depth
radius = 2; // Box corner radius
wall_thickness = 7; // Wall thickness
inset_distance = 1; //distance from inset side
inset_offset = 4.5;
inset_thickness = 2.5;
inset_scale_factor = -0.3;
screw_diameter = 3.2; // Diameter of screws - M3 clearance hole (3.2mm diameter)
screw_bore_diameter = 6.5;
screw_insert_diameter = 4.5;
//
difference(){
union(){
//box_top();
//rotate([180, 0, 0])
//half_box();
//translate([0, 0, (height + radius*2 + inset_distance*2)/2 + inset_offset])
//rounded_inset(width = width, height = depth, inset_scale=inset_scale_factor, hole = false);
//padding = radius*2 + inset_distance*2;
//rotate([0, 0, 90])
//translate([(depth + padding)/2 + inset_offset*1.5, (width + padding)/2 + inset_offset*1.5, 0])
//rotate([0, 0, 45])
//dowel(inset_scale=inset_scale_factor);
}
//cube([100, 100, 100]);
}
//padding = radius*2 + inset_distance*2;
//translate([(width + padding + 3)/2 + 5, (depth + padding + 3)/2, (height + padding)/2 + wall_thickness])
// counter_bored_hole();
//rounded_inset(width = height, height = width, cutout = true);
//front_face();
//bottom_face_alt();
side_face();