wobblyhead hg > 3dprints > hinged_box
diff main.scad @ 6:f2694e49cec1
added subdivisions; lid hinge overlap fix
| author | ark |
|---|---|
| date | 2026-11-16 21:03 +0100 |
| parents | fdd022a1bfb1 |
| children | 1933892bab51 |
line wrap: on
line diff
--- a/main.scad Mon Nov 16 19:26:19 2026 +0100 +++ b/main.scad Mon Nov 16 21:03:41 2026 +0100 @@ -7,8 +7,8 @@ part = "all"; // [all, body, lid, latch] // cut away the -y half in preview preview_cut = false; -// show a paper stack mockup in the assembly view -preview_paper = false; +// show a content mockup in each cell in the assembly view +preview_content = false; // show the filament pins and latch bar in the assembly view preview_hardware = false; // lid opening angle in the assembly view @@ -17,20 +17,32 @@ preview_latch_angle = 0; // [0:1:75] /* [box] */ -// inner size front to back -inner_depth = 92; // [10:1:300] -// inner size left to right, the thickness of the paper stack -inner_width = 92; // [10:1:300] +// inner size front to back, of one cell +inner_depth = 92; // [10:.1:300] +// inner size left to right of one cell +inner_width = 92; // [10:.1:300] // inner height, floor to lid ceiling -inner_height = 92; // [10:1:300] +inner_height = 92; // [10:.1:300] // share of the inner height taken by the body body_ratio = .85; // [.1:.01:.99] // radius of the vertical outer edges edge_radius = 2; // [0:.1:10] -// paper size front to back, for the preview mockup and the lid sweep check -paper_depth = 90; // [10:1:300] -// paper height, for the preview mockup and the lid sweep check -paper_height = 90; // [10:1:300] + +/* [dividers] */ +// number of cells left to right. inner_width is the width of one cell +columns = 1; // [1:1:10] +// number of cells front to back. inner_depth is the depth of one cell +rows = 1; // [1:1:10] +// divider wall thickness in extrusions +divider_lines = 2; // [1:1:10] + +/* [content] */ +// content size front to back, for the preview mockup and the lid sweep check. at most the cell depth +content_depth = 90; // [1:.1:300] +// content size left to right, for the preview mockup. at most the cell width +content_width = 90; // [1:.1:300] +// content height, for the preview mockup and the lid sweep check. at most the inner height +content_height = 90; // [1:.1:300] /* [walls] */ // wall thickness in extrusions @@ -85,8 +97,12 @@ lip_h = lip_layers*lh; floor_t = floor_layers*lh; chamfer_h = chamfer_layers*lh; -out_x = inner_depth + 2*wall_t; -out_y = inner_width + 2*wall_t; +// dividers and the total inner size over all cells +div_t = divider_lines*lw; +in_x = rows*inner_depth + (rows - 1)*div_t; +in_y = columns*inner_width + (columns - 1)*div_t; +out_x = in_x + 2*wall_t; +out_y = in_y + 2*wall_t; edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon); // knuckles, shared by hinge and latch @@ -150,14 +166,27 @@ assert(body_ih > 0, "inner height too low for the lid"); assert(chamfer_h <= floor_t, "chamfer higher than the floor"); -// lid sweep over a centred paper stack: radius of the lowest lid ceiling -// point over the paper minus radius of the paper's front top corner +// cell centres: x for row i from the front, y for column j from the left +function _cell_x(i) = -in_x/2 + inner_depth/2 + i*(inner_depth + div_t); +function _cell_y(j) = -in_y/2 + inner_width/2 + j*(inner_width + div_t); + +// content, clamped to one cell +cont_x = min(content_depth, inner_depth); +cont_y = min(content_width, inner_width); +cont_z = min(content_height, inner_height); + +// lid sweep over the content centred in the front row, the one furthest +// from the hinge: radius of the lowest lid ceiling point over the content +// minus radius of the content's front top corner sweep_margin = - norm([hinge_x + inner_depth/2, lip_h + lh]) - - norm([hinge_x + paper_depth/2, floor_t + paper_height - seam_z]); + norm([hinge_x + in_x/2, lip_h + lh]) + - norm([hinge_x - _cell_x(0) + cont_x/2, floor_t + cont_z - seam_z]); echo("wall thickness", wall_t, "mm", wall_lines, "extrusions"); echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm"); +if (columns > 1 || rows > 1) + echo("divider thickness", div_t, "mm", divider_lines, "extrusions"); +echo("inner size", in_x, in_y, inner_height, "mm"); echo("outer size", out_x, out_y, top_z, "mm"); echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers"); if (body_ih < body_ih_req) @@ -171,7 +200,14 @@ echo("hinge knuckle length", knuckle_l, "mm"); echo("latch plate outer face", plate_u + plate_t, "mm from the front"); echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); -echo("lid sweep clearance over centred paper", sweep_margin, "mm"); +if (cont_x < content_depth) + echo(str("WARNING: content_depth ", content_depth, " is larger than the cell, using ", cont_x)); +if (cont_y < content_width) + echo(str("WARNING: content_width ", content_width, " is larger than the cell, using ", cont_y)); +if (cont_z < content_height) + echo(str("WARNING: content_height ", content_height, " is larger than the inner height, using ", + cont_z)); +echo("lid sweep clearance over the content in the front row", sweep_margin, "mm"); // rounded box outline, inset by d module _outline(d) { @@ -220,6 +256,16 @@ } module body() { + // divider walls between the cells, reaching into the outer wall + module _dividers() { + for (j = [1:1:columns - 1]) + translate([-in_x/2 - epsilon, _cell_y(j) - inner_width/2 - div_t]) + square([in_x + 2*epsilon, div_t]); + for (i = [1:1:rows - 1]) + translate([_cell_x(i) - inner_depth/2 - div_t, -in_y/2 - epsilon]) + square([div_t, in_y + 2*epsilon]); + } + // knuckle at height z with a web down to the wall up to z1, chamfered // below for printing module _knuckle(z, z1) { @@ -249,25 +295,35 @@ _hinge_pin(); _bar_pin(); } + // dividers from the floor to the top of the lip + translate([0, 0, floor_t - epsilon]) + linear_extrude(seam_z + lip_h - floor_t + epsilon) _dividers(); } // in assembly position, closed module lid() { // knuckle at height z with a web up to the wall from z0, chamfered - // towards the lid top for printing upside down. the web reaches into - // the wall by the chamfer height, so where it meets the lid top it - // fills the edge chamfer. a knuckle that would reach past the lid top - // is cut off there and stands on the print bed + // towards the lid top for printing upside down. the web joins the wall + // through a strip one epsilon thick just inside the outer face, so it + // stays out of the body wall below the seam. where the web reaches the + // edge chamfer at the lid top, a block fills the chamfer. a knuckle that + // would reach past the lid top is cut off there and stands on the print + // bed module _knuckle(z, z0) { - web_u = chamfer_h + epsilon; + web_z1 = z + knuckle_r + knuckle_u; + fill_z0 = max(z0, top_z - chamfer_h); intersection() { - hull() { - translate([knuckle_u, z]) circle(r=knuckle_r); - translate([-web_u, z0]) - square([web_u, z + knuckle_r + knuckle_u - z0]); + union() { + hull() { + translate([knuckle_u, z]) circle(r=knuckle_r); + translate([-epsilon, z0]) square([epsilon, web_z1 - z0]); + } + if (web_z1 > fill_z0) + translate([-chamfer_h - epsilon, fill_z0]) + square([chamfer_h + epsilon, web_z1 - fill_z0]); } - translate([-web_u - 1, z - knuckle_r - 1]) - square([web_u + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]); + translate([-epsilon - 1, z - knuckle_r - 1]) + square([epsilon + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]); } } @@ -327,11 +383,12 @@ } } -module _paper() { - stack_t = inner_width - 2; +// content block centred in each cell +module _content() { color("white", .6) - translate([-paper_depth/2, -stack_t/2, floor_t]) - cube([paper_depth, stack_t, paper_height]); + for (i = [0:1:rows - 1], j = [0:1:columns - 1]) + translate([_cell_x(i) - cont_x/2, _cell_y(j) - cont_y/2, floor_t]) + cube([cont_x, cont_y, cont_z]); } // filament of length l along y at x, z @@ -353,7 +410,7 @@ translate([latch_x, 0, latch_z]) rotate([0, preview_latch_angle, 0]) translate([-latch_x, 0, -latch_z]) color("orange") latch(); } - if (preview_paper && $preview) _paper(); + if (preview_content && $preview) _content(); } module part_view() { @@ -389,6 +446,7 @@ function paramstring(prefix="", suffix="") = str( prefix, part == "all" ? "" : str(part, "_"), + columns > 1 || rows > 1 ? str("c", columns, "r", rows, "_") : "", "w", inner_width, "d", inner_depth, "h", inner_height, "b", round(100*body_ih/inner_height), "_lw", round(100*line_width), "lh", round(100*layer_height),
