[project_box] Fix dimensions and cutouts

Carefully apply internal and external dimensions to translations, and
update the cutouts to apply directly to the surfaces they're cutting
through.
This commit is contained in:
Correl Roush 2022-12-07 12:43:59 -05:00
parent 4fabdf070d
commit 63b7d76b17

View file

@ -92,12 +92,18 @@ module project_box(box,
support_radius=5, support_radius=5,
wall_width=3, wall_width=3,
mode="case") { mode="case") {
width=box.x + (fit_tolerance * 2); internal_width = box.x + (fit_tolerance * 2); // tolerance on either side
depth=box.y + (fit_tolerance * 2); internal_depth = box.y + (fit_tolerance * 2); // tolerance on either side
lid_width = width + wall_width; // Extends halfway into each side wall
lid_depth = depth + wall_width; // Extends out of one wall internal_height = (fit_tolerance // top tolerance
+ box.z // project height
+ board_thickness // board height
+ below // bottom clearance
+ fit_tolerance); // bottom tolerance
lid_width = internal_width + wall_width; // Extends halfway into each side wall
lid_depth = internal_depth + wall_width; // Extends out of one wall
lid_height = wall_width; // Replaces most of the top wall lid_height = wall_width; // Replaces most of the top wall
height=board_thickness + box.z + below + (fit_tolerance * 2) + lid_height;
// case // case
if ((mode == "case") || (mode == "all")) { if ((mode == "case") || (mode == "all")) {
@ -105,14 +111,14 @@ module project_box(box,
union() { union() {
// hollow shell // hollow shell
difference() { difference() {
_rounded_box([width + (wall_width * 2), _rounded_box([internal_width + (wall_width * 2),
depth + (wall_width * 2), internal_depth + (wall_width * 2),
height + (wall_width * 2)], internal_height + (wall_width * 2)],
r=corner_radius); r=corner_radius);
translate([wall_width,wall_width,wall_width]) translate([wall_width,wall_width,wall_width + 0.002])
cube([width, depth, height + (wall_width * 2)]); cube([internal_width, internal_depth, internal_height]);
// lid slot // lid slot
translate([wall_width / 2, wall_width, height + wall_width + 0.001]) { translate([wall_width / 2, wall_width, internal_height + wall_width + 0.001]) {
lid_base([lid_width, lid_depth, lid_height]); lid_base([lid_width, lid_depth, lid_height]);
} }
} }
@ -120,13 +126,13 @@ module project_box(box,
translate([wall_width,wall_width,wall_width]) { translate([wall_width,wall_width,wall_width]) {
translate([0,0,0]) translate([0,0,0])
corner_post(h=below, r=support_radius); corner_post(h=below, r=support_radius);
translate([width,0,0]) translate([internal_width, 0, 0])
rotate([0,0,90]) rotate([0,0,90])
corner_post(h=below, r=support_radius); corner_post(h=below, r=support_radius);
translate([0,depth,0]) translate([0,internal_depth, 0])
rotate([0,0,270]) rotate([0,0,270])
corner_post(h=below, r=support_radius); corner_post(h=below, r=support_radius);
translate([width,depth,0]) translate([internal_width, internal_depth, 0])
rotate([0,0,180]) rotate([0,0,180])
corner_post(h=below, r=support_radius); corner_post(h=below, r=support_radius);
} }
@ -139,7 +145,7 @@ module project_box(box,
translate([0,box.y / 2 - nub_width / 2,nub_height]) translate([0,box.y / 2 - nub_width / 2,nub_height])
rotate([270,0,0]) rotate([270,0,0])
cylinder(h=nub_width, r=nub_size/2); cylinder(h=nub_width, r=nub_size/2);
translate([width,box.y / 2 - nub_width / 2,nub_height]) translate([internal_width,box.y / 2 - nub_width / 2,nub_height])
rotate([270,0,0]) rotate([270,0,0])
cylinder(h=nub_width, r=nub_size/2); cylinder(h=nub_width, r=nub_size/2);
} }
@ -147,7 +153,7 @@ module project_box(box,
// lid // lid
translate([wall_width / 2 + fit_tolerance, translate([wall_width / 2 + fit_tolerance,
wall_width + fit_tolerance, wall_width + fit_tolerance,
height + wall_width + fit_tolerance]) { internal_height + wall_width + fit_tolerance]) {
lid([lid_width - (fit_tolerance * 2), lid([lid_width - (fit_tolerance * 2),
lid_depth - (fit_tolerance * 2), lid_depth - (fit_tolerance * 2),
lid_height - (fit_tolerance * 2)]); lid_height - (fit_tolerance * 2)]);
@ -155,7 +161,9 @@ module project_box(box,
} }
} }
// cutouts // cutouts
translate([wall_width + fit_tolerance, wall_width + fit_tolerance, wall_width + below]) translate([wall_width + fit_tolerance,
wall_width + fit_tolerance,
fit_tolerance + wall_width + below + board_thickness])
children(); children();
} }
} else if (mode == "lid") { } else if (mode == "lid") {
@ -174,34 +182,36 @@ module project_box(box,
} }
} }
module cutout_front(box) { module cutout_front(box, wall_width=3, fit_tolerance=0.5) {
rotate([90, 0, 0]) rotate([90, 0, 0])
linear_extrude(height=box.y * 2) linear_extrude(height=wall_width + fit_tolerance + 0.001)
children(0); children(0);
} }
module cutout_back(box) { module cutout_back(box, wall_width=3, fit_tolerance=0.5) {
translate([box.x,0,0]) translate([box.x,box.y,0])
rotate([90, 0, 180]) rotate([90, 0, 180])
linear_extrude(height=box.y * 2) linear_extrude(height=wall_width + fit_tolerance + .001)
children(0); children(0);
} }
module cutout_right(box) { module cutout_right(box, wall_width=3, fit_tolerance=0.5) {
translate([box.x,0,0])
rotate([90, 0, 90]) rotate([90, 0, 90])
linear_extrude(height=box.x * 2) linear_extrude(height=wall_width + fit_tolerance + 0.001)
children(0); children(0);
} }
module cutout_left(box) { module cutout_left(box, wall_width=3, fit_tolerance=0.5) {
translate([box.x, box.y, 0]) translate([0, box.y, 0])
rotate([90, 0, 270]) rotate([90, 0, 270])
linear_extrude(height=box.x * 2) linear_extrude(height=wall_width + fit_tolerance + 0.001)
children(0); children(0);
} }
module cutout_top(box) { module cutout_top(box, wall_width=3, fit_tolerance=0.5) {
linear_extrude(height=box.y * 2) translate([0, 0, box.z])
linear_extrude(height=wall_width + fit_tolerance + 0.001)
children(0); children(0);
} }