changeset 2:e8b0aed6e3d8

adjusted lid hinge knuckles to maximise body ratio
author ark
date 2026-11-06 22:34 +0100
parents d17ae0060cba
children a9b270c1da96
files .hgignore main.json main.scad
diffstat 3 files changed, 106 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Oct 16 23:26:25 2026 +0200
+++ b/.hgignore	Fri Nov 06 22:34:21 2026 +0100
@@ -1,2 +1,3 @@
 .DS_Store
 temp/
+.stl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.json	Fri Nov 06 22:34:21 2026 +0100
@@ -0,0 +1,65 @@
+{
+    "fileFormatVersion": "1",
+    "parameterSets": {
+        "cardbox 45": {
+            "body_ratio": "0.89000000000000001",
+            "chamfer_layers": "3",
+            "clearance": "0.10000000000000001",
+            "edge_radius": "2",
+            "filament_diameter": "1.8500000000000001",
+            "floor_layers": "6",
+            "hinge_knuckles": "5",
+            "hinge_lines": "2",
+            "inner_depth": "45",
+            "inner_height": "45",
+            "inner_width": "90",
+            "latch_detent": "0.29999999999999999",
+            "latch_grip": "5",
+            "latch_layers": "8",
+            "latch_width": "20",
+            "layer_height": "0.20000000000000001",
+            "line_width": "0.40000000000000002",
+            "lip_layers": "4",
+            "lip_lines": "2",
+            "paper_depth": "100",
+            "paper_height": "100",
+            "part": "all",
+            "preview_cut": "false",
+            "preview_hardware": "false",
+            "preview_latch_angle": "0",
+            "preview_lid_angle": "0",
+            "preview_paper": "false",
+            "wall_lines": "4"
+        },
+        "calling cards box": {
+            "body_ratio": "0.98999999999999999",
+            "chamfer_layers": "3",
+            "clearance": "0.10000000000000001",
+            "edge_radius": "2",
+            "filament_diameter": "1.8500000000000001",
+            "floor_layers": "6",
+            "hinge_knuckles": "5",
+            "hinge_lines": "2",
+            "inner_depth": "56",
+            "inner_height": "86",
+            "inner_width": "12",
+            "latch_detent": "0.29999999999999999",
+            "latch_grip": "5",
+            "latch_layers": "8",
+            "latch_width": "10",
+            "layer_height": "0.20000000000000001",
+            "line_width": "0.40000000000000002",
+            "lip_layers": "4",
+            "lip_lines": "2",
+            "paper_depth": "55",
+            "paper_height": "85",
+            "part": "all",
+            "preview_cut": "false",
+            "preview_hardware": "false",
+            "preview_latch_angle": "0",
+            "preview_lid_angle": "8",
+            "preview_paper": "true",
+            "wall_lines": "3"
+        }
+    }
+}
--- a/main.scad	Fri Oct 16 23:26:25 2026 +0200
+++ b/main.scad	Fri Nov 06 22:34:21 2026 +0100
@@ -24,11 +24,13 @@
 // inner height, floor to lid ceiling
 inner_height = 92; // [10:1:300]
 // share of the inner height taken by the body
-body_ratio = .85; // [.1:.01:.95]
+body_ratio = .85; // [.1:.01:.99]
 // radius of the vertical outer edges
 edge_radius = 2; // [0:.1:10]
-// paper edge length, for the preview mockup and the lid sweep check
-paper_size = 90; // [10:1:300]
+// 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]
 
 /* [walls] */
 // wall thickness in extrusions
@@ -85,12 +87,6 @@
 out_y = inner_width + 2*wall_t;
 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon);
 
-// heights. the seam between body and lid sits on a layer boundary
-body_ih = round(body_ratio*inner_height/lh)*lh;
-seam_z = floor_t + body_ih;
-top_z = floor_t + inner_height + floor_t;
-lid_h = top_z - seam_z;
-
 // knuckles, shared by hinge and latch
 pin_d = filament_diameter + 2*cl;
 knuckle_r = pin_d/2 + hinge_lines*lw;
@@ -99,6 +95,19 @@
 // axial gap between knuckles
 knuckle_gap = 2*cl;
 
+// heights. the seam between body and lid sits on a layer boundary.
+// the lid needs room for the wall around the latch pin hole, which sits
+// one knuckle radius plus clearance above the seam, and for one layer of
+// skirt wall above the recess over the lip. a body ratio that leaves less
+// is lowered to the highest layer that fits
+lid_min_h = max(2*knuckle_r + cl, floor_t + lip_h + 2*lh);
+body_ih_max = floor((inner_height + floor_t - lid_min_h)/lh)*lh;
+body_ih_req = round(body_ratio*inner_height/lh)*lh;
+body_ih = min(body_ih_req, body_ih_max);
+seam_z = floor_t + body_ih;
+top_z = floor_t + inner_height + floor_t;
+lid_h = top_z - seam_z;
+
 // hinge
 hinge_x = out_x/2 + knuckle_u;
 hinge_span = out_y - 2*edge_r;
@@ -135,22 +144,23 @@
 assert(_detent(90) > latch_detent, "latch_detent too large for the filament bar");
 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles");
 assert(latch_width <= hinge_span, "latch wider than the box front");
-assert(seam_z + knuckle_r + knuckle_u <= top_z, "lid too low for the hinge knuckles");
-assert(latch_z + knuckle_r + knuckle_u <= top_z, "lid too low for the latch knuckles");
-assert(lid_h > floor_t + lip_h + lh, "lid too low for the lip");
+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
 sweep_margin =
     norm([hinge_x + inner_depth/2, lip_h + lh])
-    - norm([hinge_x + paper_size/2, floor_t + paper_size - seam_z]);
+    - norm([hinge_x + paper_depth/2, floor_t + paper_height - seam_z]);
 
 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions");
 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm");
 echo("outer size", out_x, out_y, top_z, "mm");
 echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers");
-echo("body height", seam_z, "mm, lid height", lid_h, "mm");
+if (body_ih < body_ih_req)
+    echo(str("WARNING: body_ratio ", body_ratio, " leaves the lid too low, using ",
+        body_ih/inner_height));
+echo("body height", seam_z, "mm, lid height", lid_h, "mm, body ratio", body_ih/inner_height);
 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm");
 echo("hinge knuckle length", knuckle_l, "mm");
 echo("latch plate outer face", plate_u + plate_t, "mm from the front");
@@ -238,12 +248,20 @@
 // 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
+    // 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
     module _knuckle(z, z0) {
-        hull() {
-            translate([knuckle_u, z]) circle(r=knuckle_r);
-            translate([-epsilon, z0])
-                square([epsilon, z + knuckle_r + knuckle_u - z0]);
+        web_u = chamfer_h + epsilon;
+        intersection() {
+            hull() {
+                translate([knuckle_u, z]) circle(r=knuckle_r);
+                translate([-web_u, z0])
+                    square([web_u, z + knuckle_r + knuckle_u - z0]);
+            }
+            translate([-web_u - 1, z - knuckle_r - 1])
+                square([web_u + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]);
         }
     }
 
@@ -306,7 +324,8 @@
 module _paper() {
     stack_t = inner_width - 2;
     color("white", .6)
-        translate([-paper_size/2, -stack_t/2, floor_t]) cube([paper_size, stack_t, paper_size]);
+        translate([-paper_depth/2, -stack_t/2, floor_t])
+            cube([paper_depth, stack_t, paper_height]);
 }
 
 // filament of length l along y at x, z
@@ -365,7 +384,7 @@
     prefix,
     part == "all" ? "" : str(part, "_"),
     "w", inner_width, "d", inner_depth, "h", inner_height,
-    "b", round(100*body_ratio),
+    "b", round(100*body_ih/inner_height),
     "_lw", round(100*line_width), "lh", round(100*layer_height),
     suffix);