# HG changeset patch # User ark # Date 1794915139 -3600 # Node ID ac8f2ecb6c1861dd76c0ec39345c633bde70951e # Parent 1933892bab518fa1405506a1b5282bd450a0935c latch: block style, middle knuckle share, middle-width plate Add latch_style with a new block latch: a solid piece in the middle slot with the profile of the body knuckles, extended below the hook by latch_grip. Between knuckle and hook only the knuckle ring and the front wall remain; below the bar the opening follows the hook tip line to the back face. A notch at the bottom of the back face takes a fingernail. Add latch_middle_ratio for the share of the latch width taken by the middle knuckle, clamped with a warning so no slot is narrower than two extrusions. Add latch_plate_full. Without it the plate is only as wide as the middle slot, and the latch exports standing on its side with the plate thickness rounded up to whole extrusions. The block also prints on its side. The latch file name gets the style, and all names get the middle share when it is not .33. Extrude slabs with convexity 4 so the preview shows the block profile correctly. README updated. diff -r 1933892bab51 -r ac8f2ecb6c18 README.md --- a/README.md Tue Nov 17 08:50:46 2026 +0100 +++ b/README.md Tue Nov 17 12:32:19 2026 +0100 @@ -19,10 +19,23 @@ ones on the body. One filament pin runs through all of them. The latch hangs from two lid knuckles on a second pin. Two body knuckles -below it hold the third piece of filament as a bar. The hook at the -bottom of the latch wraps around this bar, and its tip reaches slightly -past it, so the latch snaps over the bar when closed. A grip tab below -the hook gives a finger hold. +below it hold the third piece of filament as a bar. The latch itself +sits in the slot between these knuckles. The hook at the bottom of the +latch wraps around this bar, and its tip reaches slightly past it, so +the latch snaps over the bar when closed. + +The latch comes in two styles. The plate style joins knuckle and hook +with a plate in front of the outer knuckles, and a grip tab below the +hook gives a finger hold. The plate either spans the full latch width +and prints flat, or is only as wide as the middle slot and prints +standing on its side. The block style is a solid piece with the same +rounded and sloped profile as the body knuckles. It reaches from the +latch knuckle down past the hook, and its back lies along the box front. +Between knuckle and hook, only the knuckle ring and the front wall +remain. Below the bar, the cut-out on the wall side runs from the hook +tip straight down to the back face, so the bar can leave when the latch +opens. A notch at the bottom edge of the back face takes a fingernail. +The block prints standing on its side. Wall, floor and knuckle sizes are set in extrusions and layers. The model converts them with the line width and layer height from the print @@ -34,18 +47,23 @@ presets are stored in `main.json`: "cardbox 45" and "calling cards box". Select the part to export with the `part` setting. For export, the lid is -turned upside down and the latch is laid flat, both ready to print. The -body prints as it stands. All parts use the same parameters, so export -all three without changing anything else. +turned upside down, and the latch is laid flat or stood on its side as +its style needs, both ready to print. The body prints as it stands. All +parts use the same parameters, so export all three without changing +anything else. The console lists the derived sizes: wall thickness, outer size, body and lid height, pin hole diameter, knuckle length, latch detent and the clearance of the lid over the content when it opens. The last echo line is a file name that encodes the main parameters, for example `hinged_box_w92d92h92b85_lw40lh20`. With a single part selected, the name -includes the part, as in `hinged_box_lid_w92d92h92b85_lw40lh20`. A box -with more than one cell adds the column and row count, as in -`hinged_box_c3r2_w92d92h92b85_lw40lh20`. +includes the part, as in `hinged_box_lid_w92d92h92b85_lw40lh20`. The +latch name adds its style: `plate`, `plate-middle` or `block`, as in +`hinged_box_latch_block_w92d92h92b85_lw40lh20`. A box with more than one +cell adds the column and row count, as in +`hinged_box_c3r2_w92d92h92b85_lw40lh20`. A latch middle share other than +.33 adds `lm` and the share in percent after the body ratio, as in +`hinged_box_w92d92h92b85lm50_lw40lh20`. After printing, push filament through the hinge knuckles, the latch knuckles and the bar knuckles. The pin holes are the filament diameter @@ -86,11 +104,25 @@ For the hinge, set `filament_diameter` to the filament used for pins and bar. `hinge_knuckles` is the number of hinge knuckles, an odd number. -`latch_width` is the width of the latch in mm. If it is wider than the -hinge span, the latch is narrowed to the span and the console prints a -warning with the width actually used. The hook tip has to pass -`latch_detent` mm of overlap at the bar. With 0 the latch swings freely. -`latch_hook_lines` sets the hook wall around the bar in extrusions. +`latch_style` selects the plate or the block latch. `latch_width` is the +width of the latch in mm. If it is wider than the hinge span, the latch +is narrowed to the span and the console prints a warning with the width +actually used. `latch_middle_ratio` is the share of that width taken by +the middle slot with the latch knuckle; the two outer slots share the +rest. A ratio that leaves any slot narrower than two extrusions is +clamped, with a warning. + +For the plate style, `latch_plate_full` makes the plate span the full +latch width, printed flat. Without it, the plate is as wide as the +middle slot and the latch prints on its side. `latch_layers` sets the +plate thickness in layers. On its side, that thickness is rounded up to +whole extrusions. `latch_grip` is the length of the grip tab below the +hook, or for the block style, how far the block reaches below the hook. + +The hook tip has to pass `latch_detent` mm of overlap at the bar. With 0 +the latch swings freely. `latch_hook_lines` sets the hook wall around +the bar in extrusions. On the block, the wall in front of the bar is the +larger of `latch_hook_lines` and `hinge_lines`. `line_width` and `layer_height` are the extrusion width and layer height the walls are built from. `clearance` is the gap between moving parts and diff -r 1933892bab51 -r ac8f2ecb6c18 main.scad --- a/main.scad Tue Nov 17 08:50:46 2026 +0100 +++ b/main.scad Tue Nov 17 12:32:19 2026 +0100 @@ -65,13 +65,19 @@ hinge_lines = 3; // [2:1:8] /* [latch] */ +// latch shape: a plate in front of the knuckles joining knuckle and hook, or a solid block between the bar knuckles +latch_style = "plate"; // [plate, block] // latch width latch_width = 20; // [8:1:100] -// latch plate thickness in layers, printed flat +// share of the latch width taken by the middle knuckle that carries the latch. the outer knuckles share the rest +latch_middle_ratio = .33; // [.1:.01:.9] +// plate style: plate across the full latch width, printed flat. otherwise only as wide as the middle knuckle, printed standing on its side +latch_plate_full = true; +// latch plate thickness in layers. a plate printed on its side is rounded up to whole extrusions latch_layers = 8; // [4:1:20] // radial overlap the hook tip has to pass at the filament bar. 0 for a free swinging latch latch_detent = .3; // [0:.05:.7] -// grip tab length below the hook +// grip length below the hook: the plate's grip tab, or the block's extension latch_grip = 5; // [0:.5:20] // hook wall around the filament bar, in extrusions latch_hook_lines = 3; // [2:1:8] @@ -131,8 +137,8 @@ hinge_span = out_y - 2*edge_r; knuckle_l = (hinge_span - (hinge_knuckles - 1)*knuckle_gap)/hinge_knuckles; -// latch. the flap hangs from lid knuckles and its hook wraps around a -// filament bar held by body knuckles straight below the flap axis. +// latch. the latch hangs from lid knuckles and its hook wraps around a +// filament bar held by body knuckles straight below the latch axis. // in the front frame u runs outward from the front face, z up. // a latch wider than the hinge span is narrowed to it latch_w = min(latch_width, hinge_span); @@ -145,7 +151,7 @@ hook_ri = bar_r + cl; hook_ro = hook_ri + latch_hook_lines*lw; // outer radius of the bar minus radius of the hook tip, both around the -// flap axis, for a hook reaching angle b past the bottom of the bar +// latch axis, for a hook reaching angle b past the bottom of the bar function _detent(b) = bar_h + bar_r - norm([hook_ri*sin(b), bar_h + hook_ri*cos(b)]); // bisection for the angle that gives latch_detent @@ -154,12 +160,46 @@ let(m = (lo + hi)/2) _detent(m) < latch_detent ? _hook_angle(m, hi, n - 1) : _hook_angle(lo, m, n - 1); hook_a = _hook_angle(0, 90); -plate_t = latch_layers*lh; + +// knuckle slots across the latch width: the middle one carries the latch, +// the outer ones have a lid knuckle above and a body knuckle below. a +// ratio that leaves a slot narrower than 2 extrusions is clamped +latch_span = latch_w - 2*knuckle_gap; +slot_min = 2*lw; +latch_ratio = min(max(latch_middle_ratio, slot_min/latch_span), 1 - 2*slot_min/latch_span); +latch_mid = latch_ratio*latch_span; +latch_outer = (latch_span - latch_mid)/2; +// y start of the two outer latch slots +latch_outer_y0 = [-latch_w/2, latch_mid/2 + knuckle_gap]; + +// the latch prints standing on its side, its profile in the print plane, +// unless it is a plate across the full latch width +latch_block = latch_style == "block"; +latch_on_side = latch_block || !latch_plate_full; + +// plate style. on its side, the thickness is rounded up to whole +// extrusions; the small margin keeps an exact multiple from rounding up +plate_w = latch_on_side ? latch_mid : latch_w; +plate_lines = ceil(latch_layers*lh/lw - .001); +plate_t = latch_on_side ? plate_lines*lw : latch_layers*lh; plate_u = knuckle_u + knuckle_r + 2*cl; plate_bz = bar_z - hook_ro - latch_grip; -latch_slot = (latch_w - 2*knuckle_gap)/3; -// y start of the two outer latch slots -latch_outer_y0 = [-latch_w/2, latch_slot/2 + knuckle_gap]; + +// block style: the profile of the body knuckles, reaching from the latch +// knuckle down past the hook by latch_grip. blk_r is the radius of the +// rounded front, blk_back the gap between back face and wall, blk_cz the +// centre of the lowest round and blk_bz the bottom end of the back face +blk_r = max(knuckle_r, hook_ro); +blk_back = 2*cl; +blk_cz = bar_z - latch_grip; +blk_bz = blk_cz - blk_r - (knuckle_u - blk_back); +// fingernail notch in the back face at the bottom edge: 3 extrusions +// deep, 8 extrusions high, kept 2 extrusions below the hook +nail_d = 3*lw; +nail_h = min(8*lw, bar_z - hook_ro - 2*lw - blk_bz); + +// how far the latch reaches out from the front face +latch_front_u = latch_block ? knuckle_u + blk_r : plate_u + plate_t; 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"); @@ -196,9 +236,24 @@ if (latch_w < latch_width) echo(str("WARNING: latch_width ", latch_width, " is wider than the hinge span, using ", latch_w)); +if (latch_ratio != latch_middle_ratio) + echo(str("WARNING: latch_middle_ratio ", latch_middle_ratio, + " leaves a latch knuckle narrower than 2 extrusions, using ", latch_ratio)); 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"); +echo("latch knuckle length: middle", latch_mid, "mm, outer", latch_outer, "mm"); +echo(str("latch style ", latch_style, ", printed ", latch_on_side ? "on its side" : "flat")); +if (latch_block) { + echo("latch block length below the hook", latch_grip, "mm"); + if (nail_h > 0) + echo("fingernail notch", nail_d, "mm deep, reaching", nail_h, "mm above the bottom edge"); + else + echo("WARNING: latch_grip too short for the fingernail notch"); +} else if (latch_on_side) + echo("latch plate thickness", plate_t, "mm", plate_lines, "extrusions, width", plate_w, "mm"); +else + echo("latch plate thickness", plate_t, "mm", latch_layers, "layers, width", plate_w, "mm"); +echo("latch outer face", latch_front_u, "mm from the front"); echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); if (cont_x < content_depth) echo(str("WARNING: content_depth ", content_depth, " is larger than the cell, using ", cont_x)); @@ -225,7 +280,7 @@ // extrude a 2d profile drawn in x/z between y0 and y1 module _yslab(y0, y1) { - translate([0, y1, 0]) rotate([90, 0, 0]) linear_extrude(y1 - y0) children(); + translate([0, y1, 0]) rotate([90, 0, 0]) linear_extrude(y1 - y0, convexity=4) children(); } // frame with u outward from the back face @@ -289,7 +344,7 @@ _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) _knuckle(seam_z, seam_z - cl); for (y0 = latch_outer_y0) - _front() _yslab(y0, y0 + latch_slot) _knuckle(bar_z, bar_z + knuckle_r); + _front() _yslab(y0, y0 + latch_outer) _knuckle(bar_z, bar_z + knuckle_r); } translate([0, 0, floor_t]) linear_extrude(top_z) _outline(wall_t); _hinge_pin(); @@ -334,7 +389,7 @@ _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) _knuckle(seam_z, seam_z + cl); for (y0 = latch_outer_y0) - _front() _yslab(y0, y0 + latch_slot) _knuckle(latch_z, seam_z + cl); + _front() _yslab(y0, y0 + latch_outer) _knuckle(latch_z, seam_z + cl); } translate([0, 0, seam_z - epsilon]) linear_extrude(lid_h - floor_t + epsilon) _outline(wall_t); @@ -346,39 +401,92 @@ } } -// in assembly position, closed +// in assembly position, closed. the plate style has a knuckle and a hook +// in the middle slot, joined by a plate in front of the outer knuckles. the +// block style is one solid profile across the middle slot module latch() { + tip_a = 270 - hook_a; + axis = [knuckle_u, latch_z]; + bar = [knuckle_u, bar_z]; + // length of the hook tip line from the bar centre to past the back face + tip_l = (knuckle_u + 1)/max(abs(cos(tip_a)), .1); + + // sector of radius r from angle a0 to a1, counterclockwise + module _sector(r, a0, a1) { + polygon(concat([[0, 0]], + [for (a = [a0:10:a1]) r*[cos(a), sin(a)]], + [r*[cos(a1), sin(a1)]])); + } + // hook around the bar, from the plate side down under the bar and // hook_a degrees up its wall side module _hook() { - tip_a = 270 - hook_a; difference() { hull() { translate([knuckle_u, bar_z]) circle(r=hook_ro); translate([knuckle_u, bar_z - hook_ro]) square([plate_u - knuckle_u + epsilon, hook_ro]); } - translate([knuckle_u, bar_z]) circle(r=hook_ri); + translate(bar) circle(r=hook_ri); // open wedge over the top and the wall side of the bar - translate([knuckle_u, bar_z]) - polygon(concat([[0, 0]], - [for (a = [0:10:tip_a]) 2*hook_ro*[cos(a), sin(a)]], - [2*hook_ro*[cos(tip_a), sin(tip_a)]])); + translate(bar) _sector(2*hook_ro, 0, tip_a); + } + } + + module _plate() { + _yslab(-plate_w/2, plate_w/2) + translate([plate_u, plate_bz]) square([plate_t, latch_z - plate_bz]); + _yslab(-latch_mid/2, latch_mid/2) { + hull() { + translate(axis) circle(r=knuckle_r); + translate([plate_u, latch_z - knuckle_r]) square([plate_t, knuckle_r]); + } + _hook(); + } + } + + // profile of the block: rounded at the front, the back face flat along + // the wall, sloped at the bottom like the body knuckles + module _block() { + difference() { + intersection() { + hull() { + translate(axis) circle(r=knuckle_r); + translate(bar) circle(r=blk_r); + translate([knuckle_u, blk_cz]) circle(r=blk_r); + translate([blk_back, blk_bz]) square([epsilon, latch_z - blk_bz]); + } + // keep the back face off the wall where the hook is larger + // than the knuckle + translate([blk_back, blk_bz - 1]) + square([knuckle_u + blk_r + 1, latch_z + knuckle_r - blk_bz + 2]); + } + translate(bar) circle(r=hook_ri); + // opening for the bar, leaving the knuckle ring and the front + // wall: from the knuckle down to the bar, front to the far side + // of the bar hole, and on the wall side down to the line of the + // hook tip face, which runs on through the bar centre to the + // back face + difference() { + polygon([ + bar, + bar + tip_l*[cos(tip_a), sin(tip_a)], + [-1, latch_z], + [knuckle_u + hook_ri, latch_z], + [knuckle_u + hook_ri, bar_z]]); + translate(axis) circle(r=knuckle_r); + } + // fingernail notch + if (nail_h > 0) + translate([blk_back - epsilon, blk_bz - epsilon]) + square([nail_d + epsilon, nail_h + epsilon]); } } difference() { - _front() union() { - _yslab(-latch_w/2, latch_w/2) - translate([plate_u, plate_bz]) square([plate_t, latch_z - plate_bz]); - _yslab(-latch_slot/2, latch_slot/2) { - hull() { - translate([knuckle_u, latch_z]) circle(r=knuckle_r); - translate([plate_u, latch_z - knuckle_r]) square([plate_t, knuckle_r]); - } - _hook(); - } - } + _front() + if (latch_block) _yslab(-latch_mid/2, latch_mid/2) _block(); + else _plate(); _latch_pin(); } } @@ -414,7 +522,7 @@ } module part_view() { - cut_s = max(out_x/2 + plate_u + plate_t, top_z) + cut_s = max(out_x/2 + latch_front_u, top_z) + (preview_lid_angle > 0 ? out_x : 0) + 1; if ($preview && preview_cut) difference() { @@ -437,7 +545,12 @@ else if (part == "latch") part_view() if ($preview) latch(); - else translate([latch_z, 0, out_x/2 + plate_u + plate_t]) + // on its side: the width along z, standing on the print bed + else if (latch_on_side) + translate([0, 0, latch_mid/2]) rotate([90, 0, 0]) + translate([-latch_x, 0, -latch_z]) latch(); + // flat: the plate face on the print bed + else translate([latch_z, 0, out_x/2 + latch_front_u]) rotate([0, -90, 0]) latch(); } @@ -446,9 +559,13 @@ function paramstring(prefix="", suffix="") = str( prefix, part == "all" ? "" : str(part, "_"), + part == "latch" ? + str(latch_block ? "block" : latch_plate_full ? "plate" : "plate-middle", "_") : "", 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), + // latch middle share, only when it differs from the default + round(100*latch_ratio) == 33 ? "" : str("lm", round(100*latch_ratio)), "_lw", round(100*line_width), "lh", round(100*layer_height), suffix);