digitalaudioswitch/openscad/case.scad

67 lines
1.7 KiB
OpenSCAD
Raw Normal View History

2023-06-06 04:14:58 +00:00
$fn = 50;
include <pcb_mount.scad>;
MODE = "all"; // ["all", mounting_bracket", "case"]
TOLERANCE=0.5;
wall_width = 3;
side_padding = 10;
case_width = pcb_width + (wall_width * 2) + (TOLERANCE * 2) + (side_padding * 2);
case_depth = pcb_height + (wall_width * 2) + (TOLERANCE * 2);
bottom_height = 30;
pcb_spacing = 10;
pcb_thickness = 1.6;
inside_offset = [wall_width + TOLERANCE + side_padding,wall_width + TOLERANCE,wall_width];
module rounded_box(box, r) {
hull() {
cylinder(r=r,h=box.z);
translate([0,box.y])
cylinder(r=r,h=box.z);
translate([box.x,0])
cylinder(r=r,h=box.z);
translate([box.x, box.y])
cylinder(r=r,h=box.z);
}
}
2023-06-06 04:14:58 +00:00
module case() {
difference() {
rounded_box(box=[case_width, case_depth, bottom_height], r=wall_width);
translate([wall_width,wall_width,wall_width + 1])
rounded_box(box=[pcb_width + (TOLERANCE * 2) + (side_padding * 2),
pcb_height + (TOLERANCE * 2),
bottom_height],
r=wall_width);
translate(inside_offset - [0,0,wall_width + 0.5]) {
drill_hole_cutouts(h=pcb_spacing);
posts(w=wall_width, h=wall_width/2 + 0.5);
}
}
}
if (MODE == "mounting_bracket") {
color("purple")
translate(inside_offset)
pcb_mount(w=wall_width,h=pcb_spacing);
} else if (MODE == "case" || MODE == "all") {
case();
if (MODE == "all") {
color("purple")
translate(inside_offset)
pcb_mount(w=wall_width,h=pcb_spacing);
color("green", 0.5)
translate(inside_offset + [0,0,pcb_spacing]) {
difference() {
cube([pcb_width, pcb_height, pcb_thickness]);
translate([0,0,-0.5])
drill_hole_cutouts(h=pcb_thickness + 1);
}
}
}
}