annotate main.scad @ 9:4b89f95689a8

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