annotate main.scad @ 11:7bef1d0cb914 default tip

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