wobblyhead hg > 3dprints > hinged_box
annotate main.scad @ 8:ac8f2ecb6c18
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.
| author | ark |
|---|---|
| date | 2026-11-17 12:32 +0100 |
| parents | 1933892bab51 |
| children | 4b89f95689a8 |
| rev | line source |
|---|---|
| 0 | 1 // hinged box with filament hinge at the back and a hinged latch in front. |
| 2 // sized by its inner dimensions, e.g. for standing notepad paper. | |
| 3 // x runs front (-x) to back (+x), y left to right, z up. | |
| 4 | |
| 5 /* [part selection] */ | |
| 6 // part to show or export | |
| 7 part = "all"; // [all, body, lid, latch] | |
| 8 // cut away the -y half in preview | |
| 1 | 9 preview_cut = false; |
| 6 | 10 // show a content mockup in each cell in the assembly view |
| 11 preview_content = false; | |
| 0 | 12 // show the filament pins and latch bar in the assembly view |
| 13 preview_hardware = false; | |
| 14 // lid opening angle in the assembly view | |
| 15 preview_lid_angle = 0; // [0:1:180] | |
| 16 // latch opening angle in the assembly view | |
| 17 preview_latch_angle = 0; // [0:1:75] | |
| 18 | |
| 19 /* [box] */ | |
| 6 | 20 // inner size front to back, of one cell |
| 21 inner_depth = 92; // [10:.1:300] | |
| 22 // inner size left to right of one cell | |
| 23 inner_width = 92; // [10:.1:300] | |
| 0 | 24 // inner height, floor to lid ceiling |
| 6 | 25 inner_height = 92; // [10:.1:300] |
| 0 | 26 // share of the inner height taken by the body |
| 2 | 27 body_ratio = .85; // [.1:.01:.99] |
| 0 | 28 // radius of the vertical outer edges |
| 29 edge_radius = 2; // [0:.1:10] | |
| 6 | 30 |
| 31 /* [dividers] */ | |
| 32 // number of cells left to right. inner_width is the width of one cell | |
| 33 columns = 1; // [1:1:10] | |
| 34 // number of cells front to back. inner_depth is the depth of one cell | |
| 35 rows = 1; // [1:1:10] | |
| 36 // divider wall thickness in extrusions | |
| 37 divider_lines = 2; // [1:1:10] | |
| 38 | |
| 39 /* [content] */ | |
| 40 // content size front to back, for the preview mockup and the lid sweep check. at most the cell depth | |
| 41 content_depth = 90; // [1:.1:300] | |
| 42 // content size left to right, for the preview mockup. at most the cell width | |
| 43 content_width = 90; // [1:.1:300] | |
| 44 // content height, for the preview mockup and the lid sweep check. at most the inner height | |
| 45 content_height = 90; // [1:.1:300] | |
| 0 | 46 |
| 47 /* [walls] */ | |
| 48 // wall thickness in extrusions | |
| 49 wall_lines = 4; // [2:1:10] | |
| 50 // lip thickness in extrusions: the inner part of the body wall, raised into the lid | |
| 51 lip_lines = 2; // [1:1:8] | |
| 52 // lip height in layers | |
| 53 lip_layers = 4; // [1:1:20] | |
| 54 // floor and lid top thickness in layers | |
| 55 floor_layers = 6; // [2:1:20] | |
| 1 | 56 // chamfer height in layers at the build plate edges of body and lid. each layer steps in by one layer height |
| 57 chamfer_layers = 3; // [0:1:10] | |
| 0 | 58 |
| 59 /* [hinge] */ | |
| 60 // diameter of the filament used as hinge pin | |
| 7 | 61 filament_diameter = 1.85; // [1:.05:3] |
| 0 | 62 // number of hinge knuckles. the body gets the outer ones |
| 63 hinge_knuckles = 5; // [3:2:15] | |
| 64 // knuckle wall around the pin hole, in extrusions | |
| 65 hinge_lines = 3; // [2:1:8] | |
| 66 | |
| 67 /* [latch] */ | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
68 // latch shape: a plate in front of the knuckles joining knuckle and hook, or a solid block between the bar knuckles |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
69 latch_style = "plate"; // [plate, block] |
| 0 | 70 // latch width |
| 71 latch_width = 20; // [8:1:100] | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
72 // share of the latch width taken by the middle knuckle that carries the latch. the outer knuckles share the rest |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
73 latch_middle_ratio = .33; // [.1:.01:.9] |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
74 // plate style: plate across the full latch width, printed flat. otherwise only as wide as the middle knuckle, printed standing on its side |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
75 latch_plate_full = true; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
76 // latch plate thickness in layers. a plate printed on its side is rounded up to whole extrusions |
| 0 | 77 latch_layers = 8; // [4:1:20] |
| 78 // radial overlap the hook tip has to pass at the filament bar. 0 for a free swinging latch | |
| 79 latch_detent = .3; // [0:.05:.7] | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
80 // grip length below the hook: the plate's grip tab, or the block's extension |
| 0 | 81 latch_grip = 5; // [0:.5:20] |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
82 // hook wall around the filament bar, in extrusions |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
83 latch_hook_lines = 3; // [2:1:8] |
| 0 | 84 |
| 85 /* [print settings] */ | |
| 86 line_width = .4; // [0:.01:1] | |
| 87 layer_height = .2; // [0:.01:.5] | |
| 88 clearance = .1; // [0:.01:.5] | |
| 89 | |
| 90 module dummy() {} | |
| 91 | |
| 92 epsilon = .001; | |
| 93 $fn = $preview ? 60 : 180; | |
| 94 | |
| 95 lw = line_width; | |
| 96 lh = layer_height; | |
| 97 cl = clearance; | |
| 98 | |
| 99 // walls | |
| 100 wall_t = wall_lines*lw; | |
| 101 // lid wall part that overlaps the lip from outside | |
| 102 skirt_t = (wall_lines - lip_lines)*lw; | |
| 103 lip_h = lip_layers*lh; | |
| 104 floor_t = floor_layers*lh; | |
| 1 | 105 chamfer_h = chamfer_layers*lh; |
| 6 | 106 // dividers and the total inner size over all cells |
| 107 div_t = divider_lines*lw; | |
| 108 in_x = rows*inner_depth + (rows - 1)*div_t; | |
| 109 in_y = columns*inner_width + (columns - 1)*div_t; | |
| 110 out_x = in_x + 2*wall_t; | |
| 111 out_y = in_y + 2*wall_t; | |
| 0 | 112 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon); |
| 113 | |
| 114 // knuckles, shared by hinge and latch | |
| 115 pin_d = filament_diameter + 2*cl; | |
| 116 knuckle_r = pin_d/2 + hinge_lines*lw; | |
| 117 // axis distance from the outer wall face | |
| 118 knuckle_u = knuckle_r + 2*cl; | |
| 119 // axial gap between knuckles | |
| 120 knuckle_gap = 2*cl; | |
| 121 | |
| 2 | 122 // heights. the seam between body and lid sits on a layer boundary. |
| 123 // the lid needs room for the wall around the latch pin hole, which sits | |
| 124 // one knuckle radius plus clearance above the seam, and for one layer of | |
| 125 // skirt wall above the recess over the lip. a body ratio that leaves less | |
| 126 // is lowered to the highest layer that fits | |
| 127 lid_min_h = max(2*knuckle_r + cl, floor_t + lip_h + 2*lh); | |
| 128 body_ih_max = floor((inner_height + floor_t - lid_min_h)/lh)*lh; | |
| 129 body_ih_req = round(body_ratio*inner_height/lh)*lh; | |
| 130 body_ih = min(body_ih_req, body_ih_max); | |
| 131 seam_z = floor_t + body_ih; | |
| 132 top_z = floor_t + inner_height + floor_t; | |
| 133 lid_h = top_z - seam_z; | |
| 134 | |
| 0 | 135 // hinge |
| 136 hinge_x = out_x/2 + knuckle_u; | |
| 137 hinge_span = out_y - 2*edge_r; | |
| 138 knuckle_l = (hinge_span - (hinge_knuckles - 1)*knuckle_gap)/hinge_knuckles; | |
| 139 | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
140 // latch. the latch hangs from lid knuckles and its hook wraps around a |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
141 // filament bar held by body knuckles straight below the latch axis. |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
142 // in the front frame u runs outward from the front face, z up. |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
143 // a latch wider than the hinge span is narrowed to it |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
144 latch_w = min(latch_width, hinge_span); |
| 0 | 145 latch_x = -out_x/2 - knuckle_u; |
| 146 latch_z = seam_z + knuckle_r + cl; | |
| 147 bar_z = seam_z - cl - knuckle_r; | |
| 148 bar_r = filament_diameter/2; | |
| 149 // distance between flap axis and bar axis | |
| 150 bar_h = latch_z - bar_z; | |
| 151 hook_ri = bar_r + cl; | |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
152 hook_ro = hook_ri + latch_hook_lines*lw; |
| 0 | 153 // outer radius of the bar minus radius of the hook tip, both around the |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
154 // latch axis, for a hook reaching angle b past the bottom of the bar |
| 0 | 155 function _detent(b) = |
| 156 bar_h + bar_r - norm([hook_ri*sin(b), bar_h + hook_ri*cos(b)]); | |
| 157 // bisection for the angle that gives latch_detent | |
| 158 function _hook_angle(lo, hi, n=40) = | |
| 159 n == 0 ? (lo + hi)/2 : | |
| 160 let(m = (lo + hi)/2) | |
| 161 _detent(m) < latch_detent ? _hook_angle(m, hi, n - 1) : _hook_angle(lo, m, n - 1); | |
| 162 hook_a = _hook_angle(0, 90); | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
163 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
164 // knuckle slots across the latch width: the middle one carries the latch, |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
165 // the outer ones have a lid knuckle above and a body knuckle below. a |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
166 // ratio that leaves a slot narrower than 2 extrusions is clamped |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
167 latch_span = latch_w - 2*knuckle_gap; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
168 slot_min = 2*lw; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
169 latch_ratio = min(max(latch_middle_ratio, slot_min/latch_span), 1 - 2*slot_min/latch_span); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
170 latch_mid = latch_ratio*latch_span; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
171 latch_outer = (latch_span - latch_mid)/2; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
172 // y start of the two outer latch slots |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
173 latch_outer_y0 = [-latch_w/2, latch_mid/2 + knuckle_gap]; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
174 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
175 // the latch prints standing on its side, its profile in the print plane, |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
176 // unless it is a plate across the full latch width |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
177 latch_block = latch_style == "block"; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
178 latch_on_side = latch_block || !latch_plate_full; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
179 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
180 // plate style. on its side, the thickness is rounded up to whole |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
181 // extrusions; the small margin keeps an exact multiple from rounding up |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
182 plate_w = latch_on_side ? latch_mid : latch_w; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
183 plate_lines = ceil(latch_layers*lh/lw - .001); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
184 plate_t = latch_on_side ? plate_lines*lw : latch_layers*lh; |
| 0 | 185 plate_u = knuckle_u + knuckle_r + 2*cl; |
| 186 plate_bz = bar_z - hook_ro - latch_grip; | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
187 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
188 // block style: the profile of the body knuckles, reaching from the latch |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
189 // knuckle down past the hook by latch_grip. blk_r is the radius of the |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
190 // rounded front, blk_back the gap between back face and wall, blk_cz the |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
191 // centre of the lowest round and blk_bz the bottom end of the back face |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
192 blk_r = max(knuckle_r, hook_ro); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
193 blk_back = 2*cl; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
194 blk_cz = bar_z - latch_grip; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
195 blk_bz = blk_cz - blk_r - (knuckle_u - blk_back); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
196 // fingernail notch in the back face at the bottom edge: 3 extrusions |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
197 // deep, 8 extrusions high, kept 2 extrusions below the hook |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
198 nail_d = 3*lw; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
199 nail_h = min(8*lw, bar_z - hook_ro - 2*lw - blk_bz); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
200 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
201 // how far the latch reaches out from the front face |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
202 latch_front_u = latch_block ? knuckle_u + blk_r : plate_u + plate_t; |
| 0 | 203 |
| 204 assert(_detent(90) > latch_detent, "latch_detent too large for the filament bar"); | |
| 205 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles"); | |
| 2 | 206 assert(body_ih > 0, "inner height too low for the lid"); |
| 1 | 207 assert(chamfer_h <= floor_t, "chamfer higher than the floor"); |
| 0 | 208 |
| 6 | 209 // cell centres: x for row i from the front, y for column j from the left |
| 210 function _cell_x(i) = -in_x/2 + inner_depth/2 + i*(inner_depth + div_t); | |
| 211 function _cell_y(j) = -in_y/2 + inner_width/2 + j*(inner_width + div_t); | |
| 212 | |
| 213 // content, clamped to one cell | |
| 214 cont_x = min(content_depth, inner_depth); | |
| 215 cont_y = min(content_width, inner_width); | |
| 216 cont_z = min(content_height, inner_height); | |
| 217 | |
| 218 // lid sweep over the content centred in the front row, the one furthest | |
| 219 // from the hinge: radius of the lowest lid ceiling point over the content | |
| 220 // minus radius of the content's front top corner | |
| 0 | 221 sweep_margin = |
| 6 | 222 norm([hinge_x + in_x/2, lip_h + lh]) |
| 223 - norm([hinge_x - _cell_x(0) + cont_x/2, floor_t + cont_z - seam_z]); | |
| 0 | 224 |
| 225 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions"); | |
| 226 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm"); | |
| 6 | 227 if (columns > 1 || rows > 1) |
| 228 echo("divider thickness", div_t, "mm", divider_lines, "extrusions"); | |
| 229 echo("inner size", in_x, in_y, inner_height, "mm"); | |
| 0 | 230 echo("outer size", out_x, out_y, top_z, "mm"); |
| 1 | 231 echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers"); |
| 2 | 232 if (body_ih < body_ih_req) |
| 233 echo(str("WARNING: body_ratio ", body_ratio, " leaves the lid too low, using ", | |
| 234 body_ih/inner_height)); | |
| 235 echo("body height", seam_z, "mm, lid height", lid_h, "mm, body ratio", body_ih/inner_height); | |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
236 if (latch_w < latch_width) |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
237 echo(str("WARNING: latch_width ", latch_width, " is wider than the hinge span, using ", |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
238 latch_w)); |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
239 if (latch_ratio != latch_middle_ratio) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
240 echo(str("WARNING: latch_middle_ratio ", latch_middle_ratio, |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
241 " leaves a latch knuckle narrower than 2 extrusions, using ", latch_ratio)); |
| 0 | 242 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm"); |
| 243 echo("hinge knuckle length", knuckle_l, "mm"); | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
244 echo("latch knuckle length: middle", latch_mid, "mm, outer", latch_outer, "mm"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
245 echo(str("latch style ", latch_style, ", printed ", latch_on_side ? "on its side" : "flat")); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
246 if (latch_block) { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
247 echo("latch block length below the hook", latch_grip, "mm"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
248 if (nail_h > 0) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
249 echo("fingernail notch", nail_d, "mm deep, reaching", nail_h, "mm above the bottom edge"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
250 else |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
251 echo("WARNING: latch_grip too short for the fingernail notch"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
252 } else if (latch_on_side) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
253 echo("latch plate thickness", plate_t, "mm", plate_lines, "extrusions, width", plate_w, "mm"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
254 else |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
255 echo("latch plate thickness", plate_t, "mm", latch_layers, "layers, width", plate_w, "mm"); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
256 echo("latch outer face", latch_front_u, "mm from the front"); |
| 0 | 257 echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); |
| 6 | 258 if (cont_x < content_depth) |
| 259 echo(str("WARNING: content_depth ", content_depth, " is larger than the cell, using ", cont_x)); | |
| 260 if (cont_y < content_width) | |
| 261 echo(str("WARNING: content_width ", content_width, " is larger than the cell, using ", cont_y)); | |
| 262 if (cont_z < content_height) | |
| 263 echo(str("WARNING: content_height ", content_height, " is larger than the inner height, using ", | |
| 264 cont_z)); | |
| 265 echo("lid sweep clearance over the content in the front row", sweep_margin, "mm"); | |
| 0 | 266 |
| 267 // rounded box outline, inset by d | |
| 268 module _outline(d) { | |
| 269 r = max(edge_r - d, 0); | |
| 270 offset(r=r) square([out_x - 2*d - 2*r, out_y - 2*d - 2*r], center=true); | |
| 271 } | |
| 272 | |
| 1 | 273 // outer box shape of height h, the bottom edge chamfered in steps of one |
| 274 // layer, each step inset by one layer height | |
| 275 module _block(h) { | |
| 276 for (i = [0:1:chamfer_layers - 1]) | |
| 277 translate([0, 0, i*lh]) linear_extrude(lh + epsilon) _outline((chamfer_layers - i)*lh); | |
| 278 translate([0, 0, chamfer_h]) linear_extrude(h - chamfer_h) _outline(0); | |
| 279 } | |
| 280 | |
| 0 | 281 // extrude a 2d profile drawn in x/z between y0 and y1 |
| 282 module _yslab(y0, y1) { | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
283 translate([0, y1, 0]) rotate([90, 0, 0]) linear_extrude(y1 - y0, convexity=4) children(); |
| 0 | 284 } |
| 285 | |
| 286 // frame with u outward from the back face | |
| 287 module _back() { | |
| 288 translate([out_x/2, 0, 0]) children(); | |
| 289 } | |
| 290 | |
| 291 // frame with u outward from the front face | |
| 292 module _front() { | |
| 293 translate([-out_x/2, 0, 0]) mirror([1, 0, 0]) children(); | |
| 294 } | |
| 295 | |
| 296 function _knuckle_y0(i) = -hinge_span/2 + i*(knuckle_l + knuckle_gap); | |
| 297 | |
| 298 module _hinge_pin() { | |
| 299 translate([hinge_x, 0, seam_z]) rotate([90, 0, 0]) | |
| 300 cylinder(d=pin_d, h=out_y + 2, center=true); | |
| 301 } | |
| 302 | |
| 303 module _latch_pin() { | |
| 304 translate([latch_x, 0, latch_z]) rotate([90, 0, 0]) | |
| 4 | 305 cylinder(d=pin_d, h=latch_w + 2, center=true); |
| 0 | 306 } |
| 307 | |
| 308 module _bar_pin() { | |
| 309 translate([latch_x, 0, bar_z]) rotate([90, 0, 0]) | |
| 4 | 310 cylinder(d=pin_d, h=latch_w + 2, center=true); |
| 0 | 311 } |
| 312 | |
| 313 module body() { | |
| 6 | 314 // divider walls between the cells, reaching into the outer wall |
| 315 module _dividers() { | |
| 316 for (j = [1:1:columns - 1]) | |
| 317 translate([-in_x/2 - epsilon, _cell_y(j) - inner_width/2 - div_t]) | |
| 318 square([in_x + 2*epsilon, div_t]); | |
| 319 for (i = [1:1:rows - 1]) | |
| 320 translate([_cell_x(i) - inner_depth/2 - div_t, -in_y/2 - epsilon]) | |
| 321 square([div_t, in_y + 2*epsilon]); | |
| 322 } | |
| 323 | |
| 0 | 324 // knuckle at height z with a web down to the wall up to z1, chamfered |
| 325 // below for printing | |
| 326 module _knuckle(z, z1) { | |
| 327 hull() { | |
| 328 translate([knuckle_u, z]) circle(r=knuckle_r); | |
| 329 translate([-epsilon, z - knuckle_r - knuckle_u]) | |
| 330 square([epsilon, z1 - (z - knuckle_r - knuckle_u)]); | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 difference() { | |
| 335 union() { | |
| 1 | 336 _block(seam_z); |
| 0 | 337 translate([0, 0, seam_z - epsilon]) |
| 338 linear_extrude(lip_h + epsilon) | |
| 339 difference() { | |
| 340 _outline(skirt_t + cl); | |
| 341 _outline(wall_t); | |
| 342 } | |
| 343 for (i = [0:2:hinge_knuckles - 1]) | |
| 344 _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) | |
| 345 _knuckle(seam_z, seam_z - cl); | |
| 346 for (y0 = latch_outer_y0) | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
347 _front() _yslab(y0, y0 + latch_outer) _knuckle(bar_z, bar_z + knuckle_r); |
| 0 | 348 } |
| 349 translate([0, 0, floor_t]) linear_extrude(top_z) _outline(wall_t); | |
| 350 _hinge_pin(); | |
| 351 _bar_pin(); | |
| 352 } | |
| 6 | 353 // dividers from the floor to the top of the lip |
| 354 translate([0, 0, floor_t - epsilon]) | |
| 355 linear_extrude(seam_z + lip_h - floor_t + epsilon) _dividers(); | |
| 0 | 356 } |
| 357 | |
| 358 // in assembly position, closed | |
| 359 module lid() { | |
| 360 // knuckle at height z with a web up to the wall from z0, chamfered | |
| 6 | 361 // towards the lid top for printing upside down. the web joins the wall |
| 362 // through a strip one epsilon thick just inside the outer face, so it | |
| 363 // stays out of the body wall below the seam. where the web reaches the | |
| 364 // edge chamfer at the lid top, a block fills the chamfer. a knuckle that | |
| 365 // would reach past the lid top is cut off there and stands on the print | |
| 366 // bed | |
| 0 | 367 module _knuckle(z, z0) { |
| 6 | 368 web_z1 = z + knuckle_r + knuckle_u; |
| 369 fill_z0 = max(z0, top_z - chamfer_h); | |
| 2 | 370 intersection() { |
| 6 | 371 union() { |
| 372 hull() { | |
| 373 translate([knuckle_u, z]) circle(r=knuckle_r); | |
| 374 translate([-epsilon, z0]) square([epsilon, web_z1 - z0]); | |
| 375 } | |
| 376 if (web_z1 > fill_z0) | |
| 377 translate([-chamfer_h - epsilon, fill_z0]) | |
| 378 square([chamfer_h + epsilon, web_z1 - fill_z0]); | |
| 2 | 379 } |
| 6 | 380 translate([-epsilon - 1, z - knuckle_r - 1]) |
| 381 square([epsilon + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]); | |
| 0 | 382 } |
| 383 } | |
| 384 | |
| 385 difference() { | |
| 386 union() { | |
| 1 | 387 translate([0, 0, top_z]) mirror([0, 0, 1]) _block(lid_h); |
| 0 | 388 for (i = [1:2:hinge_knuckles - 1]) |
| 389 _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) | |
| 390 _knuckle(seam_z, seam_z + cl); | |
| 391 for (y0 = latch_outer_y0) | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
392 _front() _yslab(y0, y0 + latch_outer) _knuckle(latch_z, seam_z + cl); |
| 0 | 393 } |
| 394 translate([0, 0, seam_z - epsilon]) | |
| 395 linear_extrude(lid_h - floor_t + epsilon) _outline(wall_t); | |
| 396 // recess over the lip, one layer higher than the lip | |
| 397 translate([0, 0, seam_z - epsilon]) | |
| 398 linear_extrude(lip_h + lh + epsilon) _outline(skirt_t); | |
| 399 _hinge_pin(); | |
| 400 _latch_pin(); | |
| 401 } | |
| 402 } | |
| 403 | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
404 // in assembly position, closed. the plate style has a knuckle and a hook |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
405 // in the middle slot, joined by a plate in front of the outer knuckles. the |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
406 // block style is one solid profile across the middle slot |
| 0 | 407 module latch() { |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
408 tip_a = 270 - hook_a; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
409 axis = [knuckle_u, latch_z]; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
410 bar = [knuckle_u, bar_z]; |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
411 // length of the hook tip line from the bar centre to past the back face |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
412 tip_l = (knuckle_u + 1)/max(abs(cos(tip_a)), .1); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
413 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
414 // sector of radius r from angle a0 to a1, counterclockwise |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
415 module _sector(r, a0, a1) { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
416 polygon(concat([[0, 0]], |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
417 [for (a = [a0:10:a1]) r*[cos(a), sin(a)]], |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
418 [r*[cos(a1), sin(a1)]])); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
419 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
420 |
| 0 | 421 // hook around the bar, from the plate side down under the bar and |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
422 // hook_a degrees up its wall side |
| 0 | 423 module _hook() { |
| 424 difference() { | |
|
5
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
425 hull() { |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
426 translate([knuckle_u, bar_z]) circle(r=hook_ro); |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
427 translate([knuckle_u, bar_z - hook_ro]) |
|
fdd022a1bfb1
reworked latch hook reinforcement, now a simple line count
ark
parents:
4
diff
changeset
|
428 square([plate_u - knuckle_u + epsilon, hook_ro]); |
| 0 | 429 } |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
430 translate(bar) circle(r=hook_ri); |
| 0 | 431 // open wedge over the top and the wall side of the bar |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
432 translate(bar) _sector(2*hook_ro, 0, tip_a); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
433 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
434 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
435 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
436 module _plate() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
437 _yslab(-plate_w/2, plate_w/2) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
438 translate([plate_u, plate_bz]) square([plate_t, latch_z - plate_bz]); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
439 _yslab(-latch_mid/2, latch_mid/2) { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
440 hull() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
441 translate(axis) circle(r=knuckle_r); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
442 translate([plate_u, latch_z - knuckle_r]) square([plate_t, knuckle_r]); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
443 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
444 _hook(); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
445 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
446 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
447 |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
448 // profile of the block: rounded at the front, the back face flat along |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
449 // the wall, sloped at the bottom like the body knuckles |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
450 module _block() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
451 difference() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
452 intersection() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
453 hull() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
454 translate(axis) circle(r=knuckle_r); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
455 translate(bar) circle(r=blk_r); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
456 translate([knuckle_u, blk_cz]) circle(r=blk_r); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
457 translate([blk_back, blk_bz]) square([epsilon, latch_z - blk_bz]); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
458 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
459 // keep the back face off the wall where the hook is larger |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
460 // than the knuckle |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
461 translate([blk_back, blk_bz - 1]) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
462 square([knuckle_u + blk_r + 1, latch_z + knuckle_r - blk_bz + 2]); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
463 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
464 translate(bar) circle(r=hook_ri); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
465 // opening for the bar, leaving the knuckle ring and the front |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
466 // wall: from the knuckle down to the bar, front to the far side |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
467 // of the bar hole, and on the wall side down to the line of the |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
468 // hook tip face, which runs on through the bar centre to the |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
469 // back face |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
470 difference() { |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
471 polygon([ |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
472 bar, |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
473 bar + tip_l*[cos(tip_a), sin(tip_a)], |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
474 [-1, latch_z], |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
475 [knuckle_u + hook_ri, latch_z], |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
476 [knuckle_u + hook_ri, bar_z]]); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
477 translate(axis) circle(r=knuckle_r); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
478 } |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
479 // fingernail notch |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
480 if (nail_h > 0) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
481 translate([blk_back - epsilon, blk_bz - epsilon]) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
482 square([nail_d + epsilon, nail_h + epsilon]); |
| 0 | 483 } |
| 484 } | |
| 485 | |
| 486 difference() { | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
487 _front() |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
488 if (latch_block) _yslab(-latch_mid/2, latch_mid/2) _block(); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
489 else _plate(); |
| 0 | 490 _latch_pin(); |
| 491 } | |
| 492 } | |
| 493 | |
| 6 | 494 // content block centred in each cell |
| 495 module _content() { | |
| 0 | 496 color("white", .6) |
| 6 | 497 for (i = [0:1:rows - 1], j = [0:1:columns - 1]) |
| 498 translate([_cell_x(i) - cont_x/2, _cell_y(j) - cont_y/2, floor_t]) | |
| 499 cube([cont_x, cont_y, cont_z]); | |
| 0 | 500 } |
| 501 | |
| 502 // filament of length l along y at x, z | |
| 503 module _filament(x, z, l) { | |
| 504 color("dimgray") translate([x, 0, z]) rotate([90, 0, 0]) | |
| 505 cylinder(d=filament_diameter, h=l, center=true); | |
| 506 } | |
| 507 | |
| 508 module _assembly() { | |
| 509 color("steelblue") body(); | |
| 510 if (preview_hardware && $preview) { | |
| 511 _filament(hinge_x, seam_z, hinge_span); | |
| 4 | 512 _filament(latch_x, bar_z, latch_w); |
| 0 | 513 } |
| 514 translate([hinge_x, 0, seam_z]) rotate([0, preview_lid_angle, 0]) | |
| 515 translate([-hinge_x, 0, -seam_z]) { | |
| 516 color("lightsteelblue") lid(); | |
| 4 | 517 if (preview_hardware && $preview) _filament(latch_x, latch_z, latch_w); |
| 0 | 518 translate([latch_x, 0, latch_z]) rotate([0, preview_latch_angle, 0]) |
| 519 translate([-latch_x, 0, -latch_z]) color("orange") latch(); | |
| 520 } | |
| 6 | 521 if (preview_content && $preview) _content(); |
| 0 | 522 } |
| 523 | |
| 524 module part_view() { | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
525 cut_s = max(out_x/2 + latch_front_u, top_z) |
| 0 | 526 + (preview_lid_angle > 0 ? out_x : 0) + 1; |
| 527 if ($preview && preview_cut) | |
| 528 difference() { | |
| 529 children(); | |
| 530 translate([-cut_s, -cut_s, -cut_s]) cube([2*cut_s, cut_s, 2*cut_s]); | |
| 531 } | |
| 532 else | |
| 533 children(); | |
| 534 } | |
| 535 | |
| 536 module main() { | |
| 537 if (part == "all") | |
| 538 part_view() _assembly(); | |
| 539 else if (part == "body") | |
| 540 part_view() body(); | |
| 541 else if (part == "lid") | |
| 542 part_view() | |
| 543 if ($preview) lid(); | |
| 544 else translate([0, 0, top_z]) rotate([180, 0, 0]) lid(); | |
| 545 else if (part == "latch") | |
| 546 part_view() | |
| 547 if ($preview) latch(); | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
548 // on its side: the width along z, standing on the print bed |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
549 else if (latch_on_side) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
550 translate([0, 0, latch_mid/2]) rotate([90, 0, 0]) |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
551 translate([-latch_x, 0, -latch_z]) latch(); |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
552 // flat: the plate face on the print bed |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
553 else translate([latch_z, 0, out_x/2 + latch_front_u]) |
| 0 | 554 rotate([0, -90, 0]) latch(); |
| 555 } | |
| 556 | |
| 557 main(); | |
| 558 | |
| 559 function paramstring(prefix="", suffix="") = str( | |
| 560 prefix, | |
| 561 part == "all" ? "" : str(part, "_"), | |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
562 part == "latch" ? |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
563 str(latch_block ? "block" : latch_plate_full ? "plate" : "plate-middle", "_") : "", |
| 6 | 564 columns > 1 || rows > 1 ? str("c", columns, "r", rows, "_") : "", |
| 0 | 565 "w", inner_width, "d", inner_depth, "h", inner_height, |
| 2 | 566 "b", round(100*body_ih/inner_height), |
|
8
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
567 // latch middle share, only when it differs from the default |
|
ac8f2ecb6c18
latch: block style, middle knuckle share, middle-width plate
ark
parents:
7
diff
changeset
|
568 round(100*latch_ratio) == 33 ? "" : str("lm", round(100*latch_ratio)), |
| 0 | 569 "_lw", round(100*line_width), "lh", round(100*layer_height), |
| 570 suffix); | |
| 571 | |
| 572 echo(paramstring("hinged_box_")); |
