From f84cf9727c9d45ca784d968672787b9fc66abef0 Mon Sep 17 00:00:00 2001 From: Correl Date: Tue, 6 Jun 2023 21:57:22 -0400 Subject: [PATCH] Add multiple export options to the case design --- openscad/Makefile | 6 ++--- openscad/case.scad | 58 ++++++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/openscad/Makefile b/openscad/Makefile index 66ff4eb..09e6c14 100644 --- a/openscad/Makefile +++ b/openscad/Makefile @@ -1,12 +1,12 @@ .PHONY: all clean -all: case.stl +all: case.stl mounting_bracket.stl pcb_dimensions.scad: generate.py ../kicad/Digital\ Audio\ Switch.kicad_pcb python3 $< > $@ -case.stl: case.scad pcb_dimensions.scad - openscad -o $@ case.scad +%.stl: case.scad pcb_dimensions.scad + openscad -o $@ -D MODE=\"$(basename $@)\" $< clean: rm -f case.stl pcb_dimensions.scad diff --git a/openscad/case.scad b/openscad/case.scad index ed44195..b8549a3 100644 --- a/openscad/case.scad +++ b/openscad/case.scad @@ -2,6 +2,7 @@ $fn = 50; include ; +MODE = "all"; // ["all", mounting_bracket", "case"] TOLERANCE=0.5; wall_width = 3; @@ -14,18 +15,6 @@ pcb_thickness = 1.6; inside_offset = [wall_width + TOLERANCE + side_padding,wall_width + TOLERANCE,wall_width]; -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); - } -} module rounded_box(box, r) { hull() { cylinder(r=r,h=box.z); @@ -38,15 +27,40 @@ module rounded_box(box, r) { } } -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); +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); + } + } + } + }