comparison main.scad @ 6:f2694e49cec1

added subdivisions; lid hinge overlap fix
author ark
date 2026-11-16 21:03 +0100
parents fdd022a1bfb1
children 1933892bab51
comparison
equal deleted inserted replaced
5:fdd022a1bfb1 6:f2694e49cec1
5 /* [part selection] */ 5 /* [part selection] */
6 // part to show or export 6 // part to show or export
7 part = "all"; // [all, body, lid, latch] 7 part = "all"; // [all, body, lid, latch]
8 // cut away the -y half in preview 8 // cut away the -y half in preview
9 preview_cut = false; 9 preview_cut = false;
10 // show a paper stack mockup in the assembly view 10 // show a content mockup in each cell in the assembly view
11 preview_paper = false; 11 preview_content = false;
12 // show the filament pins and latch bar in the assembly view 12 // show the filament pins and latch bar in the assembly view
13 preview_hardware = false; 13 preview_hardware = false;
14 // lid opening angle in the assembly view 14 // lid opening angle in the assembly view
15 preview_lid_angle = 0; // [0:1:180] 15 preview_lid_angle = 0; // [0:1:180]
16 // latch opening angle in the assembly view 16 // latch opening angle in the assembly view
17 preview_latch_angle = 0; // [0:1:75] 17 preview_latch_angle = 0; // [0:1:75]
18 18
19 /* [box] */ 19 /* [box] */
20 // inner size front to back 20 // inner size front to back, of one cell
21 inner_depth = 92; // [10:1:300] 21 inner_depth = 92; // [10:.1:300]
22 // inner size left to right, the thickness of the paper stack 22 // inner size left to right of one cell
23 inner_width = 92; // [10:1:300] 23 inner_width = 92; // [10:.1:300]
24 // inner height, floor to lid ceiling 24 // inner height, floor to lid ceiling
25 inner_height = 92; // [10:1:300] 25 inner_height = 92; // [10:.1:300]
26 // share of the inner height taken by the body 26 // share of the inner height taken by the body
27 body_ratio = .85; // [.1:.01:.99] 27 body_ratio = .85; // [.1:.01:.99]
28 // radius of the vertical outer edges 28 // radius of the vertical outer edges
29 edge_radius = 2; // [0:.1:10] 29 edge_radius = 2; // [0:.1:10]
30 // paper size front to back, for the preview mockup and the lid sweep check 30
31 paper_depth = 90; // [10:1:300] 31 /* [dividers] */
32 // paper height, for the preview mockup and the lid sweep check 32 // number of cells left to right. inner_width is the width of one cell
33 paper_height = 90; // [10:1:300] 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]
34 46
35 /* [walls] */ 47 /* [walls] */
36 // wall thickness in extrusions 48 // wall thickness in extrusions
37 wall_lines = 4; // [2:1:10] 49 wall_lines = 4; // [2:1:10]
38 // lip thickness in extrusions: the inner part of the body wall, raised into the lid 50 // lip thickness in extrusions: the inner part of the body wall, raised into the lid
83 // lid wall part that overlaps the lip from outside 95 // lid wall part that overlaps the lip from outside
84 skirt_t = (wall_lines - lip_lines)*lw; 96 skirt_t = (wall_lines - lip_lines)*lw;
85 lip_h = lip_layers*lh; 97 lip_h = lip_layers*lh;
86 floor_t = floor_layers*lh; 98 floor_t = floor_layers*lh;
87 chamfer_h = chamfer_layers*lh; 99 chamfer_h = chamfer_layers*lh;
88 out_x = inner_depth + 2*wall_t; 100 // dividers and the total inner size over all cells
89 out_y = inner_width + 2*wall_t; 101 div_t = divider_lines*lw;
102 in_x = rows*inner_depth + (rows - 1)*div_t;
103 in_y = columns*inner_width + (columns - 1)*div_t;
104 out_x = in_x + 2*wall_t;
105 out_y = in_y + 2*wall_t;
90 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon); 106 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon);
91 107
92 // knuckles, shared by hinge and latch 108 // knuckles, shared by hinge and latch
93 pin_d = filament_diameter + 2*cl; 109 pin_d = filament_diameter + 2*cl;
94 knuckle_r = pin_d/2 + hinge_lines*lw; 110 knuckle_r = pin_d/2 + hinge_lines*lw;
148 assert(_detent(90) > latch_detent, "latch_detent too large for the filament bar"); 164 assert(_detent(90) > latch_detent, "latch_detent too large for the filament bar");
149 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles"); 165 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles");
150 assert(body_ih > 0, "inner height too low for the lid"); 166 assert(body_ih > 0, "inner height too low for the lid");
151 assert(chamfer_h <= floor_t, "chamfer higher than the floor"); 167 assert(chamfer_h <= floor_t, "chamfer higher than the floor");
152 168
153 // lid sweep over a centred paper stack: radius of the lowest lid ceiling 169 // cell centres: x for row i from the front, y for column j from the left
154 // point over the paper minus radius of the paper's front top corner 170 function _cell_x(i) = -in_x/2 + inner_depth/2 + i*(inner_depth + div_t);
171 function _cell_y(j) = -in_y/2 + inner_width/2 + j*(inner_width + div_t);
172
173 // content, clamped to one cell
174 cont_x = min(content_depth, inner_depth);
175 cont_y = min(content_width, inner_width);
176 cont_z = min(content_height, inner_height);
177
178 // lid sweep over the content centred in the front row, the one furthest
179 // from the hinge: radius of the lowest lid ceiling point over the content
180 // minus radius of the content's front top corner
155 sweep_margin = 181 sweep_margin =
156 norm([hinge_x + inner_depth/2, lip_h + lh]) 182 norm([hinge_x + in_x/2, lip_h + lh])
157 - norm([hinge_x + paper_depth/2, floor_t + paper_height - seam_z]); 183 - norm([hinge_x - _cell_x(0) + cont_x/2, floor_t + cont_z - seam_z]);
158 184
159 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions"); 185 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions");
160 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm"); 186 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm");
187 if (columns > 1 || rows > 1)
188 echo("divider thickness", div_t, "mm", divider_lines, "extrusions");
189 echo("inner size", in_x, in_y, inner_height, "mm");
161 echo("outer size", out_x, out_y, top_z, "mm"); 190 echo("outer size", out_x, out_y, top_z, "mm");
162 echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers"); 191 echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers");
163 if (body_ih < body_ih_req) 192 if (body_ih < body_ih_req)
164 echo(str("WARNING: body_ratio ", body_ratio, " leaves the lid too low, using ", 193 echo(str("WARNING: body_ratio ", body_ratio, " leaves the lid too low, using ",
165 body_ih/inner_height)); 194 body_ih/inner_height));
169 latch_w)); 198 latch_w));
170 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm"); 199 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm");
171 echo("hinge knuckle length", knuckle_l, "mm"); 200 echo("hinge knuckle length", knuckle_l, "mm");
172 echo("latch plate outer face", plate_u + plate_t, "mm from the front"); 201 echo("latch plate outer face", plate_u + plate_t, "mm from the front");
173 echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); 202 echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm");
174 echo("lid sweep clearance over centred paper", sweep_margin, "mm"); 203 if (cont_x < content_depth)
204 echo(str("WARNING: content_depth ", content_depth, " is larger than the cell, using ", cont_x));
205 if (cont_y < content_width)
206 echo(str("WARNING: content_width ", content_width, " is larger than the cell, using ", cont_y));
207 if (cont_z < content_height)
208 echo(str("WARNING: content_height ", content_height, " is larger than the inner height, using ",
209 cont_z));
210 echo("lid sweep clearance over the content in the front row", sweep_margin, "mm");
175 211
176 // rounded box outline, inset by d 212 // rounded box outline, inset by d
177 module _outline(d) { 213 module _outline(d) {
178 r = max(edge_r - d, 0); 214 r = max(edge_r - d, 0);
179 offset(r=r) square([out_x - 2*d - 2*r, out_y - 2*d - 2*r], center=true); 215 offset(r=r) square([out_x - 2*d - 2*r, out_y - 2*d - 2*r], center=true);
218 translate([latch_x, 0, bar_z]) rotate([90, 0, 0]) 254 translate([latch_x, 0, bar_z]) rotate([90, 0, 0])
219 cylinder(d=pin_d, h=latch_w + 2, center=true); 255 cylinder(d=pin_d, h=latch_w + 2, center=true);
220 } 256 }
221 257
222 module body() { 258 module body() {
259 // divider walls between the cells, reaching into the outer wall
260 module _dividers() {
261 for (j = [1:1:columns - 1])
262 translate([-in_x/2 - epsilon, _cell_y(j) - inner_width/2 - div_t])
263 square([in_x + 2*epsilon, div_t]);
264 for (i = [1:1:rows - 1])
265 translate([_cell_x(i) - inner_depth/2 - div_t, -in_y/2 - epsilon])
266 square([div_t, in_y + 2*epsilon]);
267 }
268
223 // knuckle at height z with a web down to the wall up to z1, chamfered 269 // knuckle at height z with a web down to the wall up to z1, chamfered
224 // below for printing 270 // below for printing
225 module _knuckle(z, z1) { 271 module _knuckle(z, z1) {
226 hull() { 272 hull() {
227 translate([knuckle_u, z]) circle(r=knuckle_r); 273 translate([knuckle_u, z]) circle(r=knuckle_r);
247 } 293 }
248 translate([0, 0, floor_t]) linear_extrude(top_z) _outline(wall_t); 294 translate([0, 0, floor_t]) linear_extrude(top_z) _outline(wall_t);
249 _hinge_pin(); 295 _hinge_pin();
250 _bar_pin(); 296 _bar_pin();
251 } 297 }
298 // dividers from the floor to the top of the lip
299 translate([0, 0, floor_t - epsilon])
300 linear_extrude(seam_z + lip_h - floor_t + epsilon) _dividers();
252 } 301 }
253 302
254 // in assembly position, closed 303 // in assembly position, closed
255 module lid() { 304 module lid() {
256 // knuckle at height z with a web up to the wall from z0, chamfered 305 // knuckle at height z with a web up to the wall from z0, chamfered
257 // towards the lid top for printing upside down. the web reaches into 306 // towards the lid top for printing upside down. the web joins the wall
258 // the wall by the chamfer height, so where it meets the lid top it 307 // through a strip one epsilon thick just inside the outer face, so it
259 // fills the edge chamfer. a knuckle that would reach past the lid top 308 // stays out of the body wall below the seam. where the web reaches the
260 // is cut off there and stands on the print bed 309 // edge chamfer at the lid top, a block fills the chamfer. a knuckle that
310 // would reach past the lid top is cut off there and stands on the print
311 // bed
261 module _knuckle(z, z0) { 312 module _knuckle(z, z0) {
262 web_u = chamfer_h + epsilon; 313 web_z1 = z + knuckle_r + knuckle_u;
314 fill_z0 = max(z0, top_z - chamfer_h);
263 intersection() { 315 intersection() {
264 hull() { 316 union() {
265 translate([knuckle_u, z]) circle(r=knuckle_r); 317 hull() {
266 translate([-web_u, z0]) 318 translate([knuckle_u, z]) circle(r=knuckle_r);
267 square([web_u, z + knuckle_r + knuckle_u - z0]); 319 translate([-epsilon, z0]) square([epsilon, web_z1 - z0]);
320 }
321 if (web_z1 > fill_z0)
322 translate([-chamfer_h - epsilon, fill_z0])
323 square([chamfer_h + epsilon, web_z1 - fill_z0]);
268 } 324 }
269 translate([-web_u - 1, z - knuckle_r - 1]) 325 translate([-epsilon - 1, z - knuckle_r - 1])
270 square([web_u + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]); 326 square([epsilon + knuckle_u + knuckle_r + 2, top_z - (z - knuckle_r - 1)]);
271 } 327 }
272 } 328 }
273 329
274 difference() { 330 difference() {
275 union() { 331 union() {
325 } 381 }
326 _latch_pin(); 382 _latch_pin();
327 } 383 }
328 } 384 }
329 385
330 module _paper() { 386 // content block centred in each cell
331 stack_t = inner_width - 2; 387 module _content() {
332 color("white", .6) 388 color("white", .6)
333 translate([-paper_depth/2, -stack_t/2, floor_t]) 389 for (i = [0:1:rows - 1], j = [0:1:columns - 1])
334 cube([paper_depth, stack_t, paper_height]); 390 translate([_cell_x(i) - cont_x/2, _cell_y(j) - cont_y/2, floor_t])
391 cube([cont_x, cont_y, cont_z]);
335 } 392 }
336 393
337 // filament of length l along y at x, z 394 // filament of length l along y at x, z
338 module _filament(x, z, l) { 395 module _filament(x, z, l) {
339 color("dimgray") translate([x, 0, z]) rotate([90, 0, 0]) 396 color("dimgray") translate([x, 0, z]) rotate([90, 0, 0])
351 color("lightsteelblue") lid(); 408 color("lightsteelblue") lid();
352 if (preview_hardware && $preview) _filament(latch_x, latch_z, latch_w); 409 if (preview_hardware && $preview) _filament(latch_x, latch_z, latch_w);
353 translate([latch_x, 0, latch_z]) rotate([0, preview_latch_angle, 0]) 410 translate([latch_x, 0, latch_z]) rotate([0, preview_latch_angle, 0])
354 translate([-latch_x, 0, -latch_z]) color("orange") latch(); 411 translate([-latch_x, 0, -latch_z]) color("orange") latch();
355 } 412 }
356 if (preview_paper && $preview) _paper(); 413 if (preview_content && $preview) _content();
357 } 414 }
358 415
359 module part_view() { 416 module part_view() {
360 cut_s = max(out_x/2 + plate_u + plate_t, top_z) 417 cut_s = max(out_x/2 + plate_u + plate_t, top_z)
361 + (preview_lid_angle > 0 ? out_x : 0) + 1; 418 + (preview_lid_angle > 0 ? out_x : 0) + 1;
387 main(); 444 main();
388 445
389 function paramstring(prefix="", suffix="") = str( 446 function paramstring(prefix="", suffix="") = str(
390 prefix, 447 prefix,
391 part == "all" ? "" : str(part, "_"), 448 part == "all" ? "" : str(part, "_"),
449 columns > 1 || rows > 1 ? str("c", columns, "r", rows, "_") : "",
392 "w", inner_width, "d", inner_depth, "h", inner_height, 450 "w", inner_width, "d", inner_depth, "h", inner_height,
393 "b", round(100*body_ih/inner_height), 451 "b", round(100*body_ih/inner_height),
394 "_lw", round(100*line_width), "lh", round(100*layer_height), 452 "_lw", round(100*line_width), "lh", round(100*layer_height),
395 suffix); 453 suffix);
396 454