Add more box parameters & a "holes" module for joints inside surfaces.
This commit is contained in:
parent
ecf7566467
commit
4712acae46
|
|
@ -61,84 +61,84 @@ module notches(n, width, depth=thickness) {
|
|||
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() {
|
||||
square([xsize, ysize], center=true);
|
||||
translate([0,ysize/2+0.005,0]) rotate([0,0,0]) notches(yp, xsize - 2*notch_margin);
|
||||
translate([-xsize/2-0.005,0,0]) rotate([0,0,90]) notches(xn, ysize - 2*notch_margin);
|
||||
translate([0,-ysize/2-0.005,0]) rotate([0,0,180]) notches(yn, xsize - 2*notch_margin);
|
||||
translate([xsize/2+0.005,0,0]) rotate([0,0,270]) notches(xp, ysize - 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*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*margin);
|
||||
children();
|
||||
if (inc_labels) text(label_text, size=label_size, halign="center", valign="center");
|
||||
}
|
||||
}
|
||||
|
||||
module top_cutouts() {}
|
||||
module top_side() {
|
||||
module top_side_base() {
|
||||
panel("Top", outer_width, outer_depth,
|
||||
inc_back ? -notches_w : 0,
|
||||
inc_left ? -notches_d : 0,
|
||||
inc_front ? -notches_w : 0,
|
||||
inc_right ? -notches_d : 0) {
|
||||
top_cutouts();
|
||||
}
|
||||
inc_right ? -notches_d : 0);
|
||||
}
|
||||
|
||||
module bottom_cutouts() {}
|
||||
module bottom_side() {
|
||||
module bottom_side_base() {
|
||||
panel("Bottom", outer_width, outer_depth,
|
||||
inc_front ? -notches_w : 0,
|
||||
inc_left ? -notches_d : 0,
|
||||
inc_back ? -notches_w : 0,
|
||||
inc_right ? -notches_d : 0) {
|
||||
bottom_cutouts();
|
||||
}
|
||||
inc_right ? -notches_d : 0);
|
||||
}
|
||||
|
||||
module left_cutouts() {}
|
||||
module left_side() {
|
||||
module left_side_base() {
|
||||
panel("Left", outer_depth, outer_height,
|
||||
inc_top ? notches_d : 0,
|
||||
inc_back ? -notches_h : 0,
|
||||
inc_bottom ? notches_d : 0,
|
||||
inc_front ? -notches_h : 0) {
|
||||
left_cutouts();
|
||||
}
|
||||
inc_front ? -notches_h : 0);
|
||||
}
|
||||
|
||||
module right_cutouts() {}
|
||||
module right_side() {
|
||||
module right_side_base() {
|
||||
panel("Right", outer_depth, outer_height,
|
||||
inc_top ? notches_d : 0,
|
||||
inc_front ? -notches_h : 0,
|
||||
inc_bottom ? notches_d : 0,
|
||||
inc_back ? -notches_h : 0) {
|
||||
right_cutouts();
|
||||
}
|
||||
inc_back ? -notches_h : 0);
|
||||
}
|
||||
|
||||
module front_cutouts() {}
|
||||
module front_side() {
|
||||
module front_side_base() {
|
||||
panel("Front", outer_width, outer_height,
|
||||
inc_top ? notches_w : 0,
|
||||
inc_left ? notches_h : 0,
|
||||
inc_bottom ? notches_w : 0,
|
||||
inc_right ? notches_h : 0) {
|
||||
front_cutouts();
|
||||
}
|
||||
inc_right ? notches_h : 0);
|
||||
}
|
||||
|
||||
module back_cutouts() {}
|
||||
module back_side() {
|
||||
module back_side_base() {
|
||||
panel("Back", outer_width, outer_height,
|
||||
inc_top ? notches_w : 0,
|
||||
inc_right ? notches_h : 0,
|
||||
inc_bottom ? notches_w : 0,
|
||||
inc_left ? notches_h : 0) {
|
||||
back_cutouts();
|
||||
}
|
||||
inc_left ? notches_h : 0);
|
||||
}
|
||||
|
||||
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.
|
||||
module part_layout_hdw() {
|
||||
if (inc_front) front_side();
|
||||
|
|
@ -179,17 +179,21 @@ module part_layout_wdh() {
|
|||
}
|
||||
}
|
||||
|
||||
module extra_layout() {}
|
||||
module part_layout() {
|
||||
if (outer_width > outer_height)
|
||||
part_layout_wdh();
|
||||
else
|
||||
part_layout_hdw();
|
||||
|
||||
extra_layout();
|
||||
}
|
||||
|
||||
module thicken() {
|
||||
linear_extrude(height=thickness, center=true, convexity=10) children();
|
||||
}
|
||||
|
||||
module extra_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_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_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();
|
||||
extra_assembly();
|
||||
}
|
||||
|
||||
if (mode == "assembly")
|
||||
|
|
|
|||
Loading…
Reference in New Issue