Add more box parameters & a "holes" module for joints inside surfaces.

This commit is contained in:
Jesse D. McDonald 2018-01-14 01:54:27 -06:00
parent ecf7566467
commit 4712acae46
1 changed files with 40 additions and 35 deletions

View File

@ -61,84 +61,84 @@ module notches(n, width, depth=thickness) {
else if (n > 0) notches_pos( n, width, depth); else if (n > 0) notches_pos( n, width, depth);
} }
module panel(label_text, xsize, ysize, yp, xn, yn, xp) { // For use inside a surface. Always uses the "negative" pattern.
module holes(n, width, height=thickness) {
// n notches + n-1 spaces
notch_width = width / (2*n - 1);
space_width = notch_width;
for (i = [0 : n-1]) {
translate([-width/2 + i*notch_width + i*space_width + notch_width/2, 0, 0])
square([notch_width, height], center=true);
}
}
module panel(label_text, xsize, ysize, yp, xn, yn, xp, margin=notch_margin) {
difference() { difference() {
square([xsize, ysize], center=true); square([xsize, ysize], center=true);
translate([0,ysize/2+0.005,0]) rotate([0,0,0]) notches(yp, xsize - 2*notch_margin); translate([0,ysize/2+0.005,0]) rotate([0,0,0]) notches(yp, xsize - 2*margin);
translate([-xsize/2-0.005,0,0]) rotate([0,0,90]) notches(xn, ysize - 2*notch_margin); translate([-xsize/2-0.005,0,0]) rotate([0,0,90]) notches(xn, ysize - 2*margin);
translate([0,-ysize/2-0.005,0]) rotate([0,0,180]) notches(yn, xsize - 2*notch_margin); translate([0,-ysize/2-0.005,0]) rotate([0,0,180]) notches(yn, xsize - 2*margin);
translate([xsize/2+0.005,0,0]) rotate([0,0,270]) notches(xp, ysize - 2*notch_margin); translate([xsize/2+0.005,0,0]) rotate([0,0,270]) notches(xp, ysize - 2*margin);
children(); children();
if (inc_labels) text(label_text, size=label_size, halign="center", valign="center"); if (inc_labels) text(label_text, size=label_size, halign="center", valign="center");
} }
} }
module top_cutouts() {} module top_side_base() {
module top_side() {
panel("Top", outer_width, outer_depth, panel("Top", outer_width, outer_depth,
inc_back ? -notches_w : 0, inc_back ? -notches_w : 0,
inc_left ? -notches_d : 0, inc_left ? -notches_d : 0,
inc_front ? -notches_w : 0, inc_front ? -notches_w : 0,
inc_right ? -notches_d : 0) { inc_right ? -notches_d : 0);
top_cutouts();
}
} }
module bottom_cutouts() {} module bottom_side_base() {
module bottom_side() {
panel("Bottom", outer_width, outer_depth, panel("Bottom", outer_width, outer_depth,
inc_front ? -notches_w : 0, inc_front ? -notches_w : 0,
inc_left ? -notches_d : 0, inc_left ? -notches_d : 0,
inc_back ? -notches_w : 0, inc_back ? -notches_w : 0,
inc_right ? -notches_d : 0) { inc_right ? -notches_d : 0);
bottom_cutouts();
}
} }
module left_cutouts() {} module left_side_base() {
module left_side() {
panel("Left", outer_depth, outer_height, panel("Left", outer_depth, outer_height,
inc_top ? notches_d : 0, inc_top ? notches_d : 0,
inc_back ? -notches_h : 0, inc_back ? -notches_h : 0,
inc_bottom ? notches_d : 0, inc_bottom ? notches_d : 0,
inc_front ? -notches_h : 0) { inc_front ? -notches_h : 0);
left_cutouts();
}
} }
module right_cutouts() {} module right_side_base() {
module right_side() {
panel("Right", outer_depth, outer_height, panel("Right", outer_depth, outer_height,
inc_top ? notches_d : 0, inc_top ? notches_d : 0,
inc_front ? -notches_h : 0, inc_front ? -notches_h : 0,
inc_bottom ? notches_d : 0, inc_bottom ? notches_d : 0,
inc_back ? -notches_h : 0) { inc_back ? -notches_h : 0);
right_cutouts();
}
} }
module front_cutouts() {} module front_side_base() {
module front_side() {
panel("Front", outer_width, outer_height, panel("Front", outer_width, outer_height,
inc_top ? notches_w : 0, inc_top ? notches_w : 0,
inc_left ? notches_h : 0, inc_left ? notches_h : 0,
inc_bottom ? notches_w : 0, inc_bottom ? notches_w : 0,
inc_right ? notches_h : 0) { inc_right ? notches_h : 0);
front_cutouts();
}
} }
module back_cutouts() {} module back_side_base() {
module back_side() {
panel("Back", outer_width, outer_height, panel("Back", outer_width, outer_height,
inc_top ? notches_w : 0, inc_top ? notches_w : 0,
inc_right ? notches_h : 0, inc_right ? notches_h : 0,
inc_bottom ? notches_w : 0, inc_bottom ? notches_w : 0,
inc_left ? notches_h : 0) { inc_left ? notches_h : 0);
back_cutouts();
}
} }
module top_side() { top_side_base(); }
module bottom_side() { bottom_side_base(); }
module left_side() { left_side_base(); }
module right_side() { right_side_base(); }
module front_side() { front_side_base(); }
module back_side() { back_side_base(); }
// Optimized for height > depth > width. // Optimized for height > depth > width.
module part_layout_hdw() { module part_layout_hdw() {
if (inc_front) front_side(); if (inc_front) front_side();
@ -179,17 +179,21 @@ module part_layout_wdh() {
} }
} }
module extra_layout() {}
module part_layout() { module part_layout() {
if (outer_width > outer_height) if (outer_width > outer_height)
part_layout_wdh(); part_layout_wdh();
else else
part_layout_hdw(); part_layout_hdw();
extra_layout();
} }
module thicken() { module thicken() {
linear_extrude(height=thickness, center=true, convexity=10) children(); linear_extrude(height=thickness, center=true, convexity=10) children();
} }
module extra_assembly() {}
module part_assembly() { module part_assembly() {
if (inc_left) color("red") translate([ -(outer_width/2 - thickness/2 + explode),0,0]) rotate([90,0,270]) thicken() left_side(); if (inc_left) color("red") translate([ -(outer_width/2 - thickness/2 + explode),0,0]) rotate([90,0,270]) thicken() left_side();
if (inc_front) color("green") translate([0, -(outer_depth/2 - thickness/2 + explode),0]) rotate([90,0,0]) thicken() front_side(); if (inc_front) color("green") translate([0, -(outer_depth/2 - thickness/2 + explode),0]) rotate([90,0,0]) thicken() front_side();
@ -197,6 +201,7 @@ module part_assembly() {
if (inc_back) color("yellow") translate([0, (outer_depth/2 - thickness/2 + explode),0]) rotate([90,0,180]) thicken() back_side(); if (inc_back) color("yellow") translate([0, (outer_depth/2 - thickness/2 + explode),0]) rotate([90,0,180]) thicken() back_side();
if (inc_top) color("cyan") translate([0,0, (outer_height/2 - thickness/2 + explode)]) rotate([0,0,0]) thicken() top_side(); if (inc_top) color("cyan") translate([0,0, (outer_height/2 - thickness/2 + explode)]) rotate([0,0,0]) thicken() top_side();
if (inc_bottom) color("magenta") translate([0,0,-(outer_height/2 - thickness/2 + explode)]) rotate([180,0,0]) thicken() bottom_side(); if (inc_bottom) color("magenta") translate([0,0,-(outer_height/2 - thickness/2 + explode)]) rotate([180,0,0]) thicken() bottom_side();
extra_assembly();
} }
if (mode == "assembly") if (mode == "assembly")