wobblyhead hg > 3dprints > hinged_box
comparison main.scad @ 1:d17ae0060cba
added chamfer to bottom of body and lid
| author | ark |
|---|---|
| date | 2026-10-16 23:26 +0200 |
| parents | 38eca1c6d879 |
| children | e8b0aed6e3d8 |
comparison
equal
deleted
inserted
replaced
| 0:38eca1c6d879 | 1:d17ae0060cba |
|---|---|
| 4 | 4 |
| 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 = true; | 9 preview_cut = false; |
| 10 // show a paper stack mockup in the assembly view | 10 // show a paper stack mockup in the assembly view |
| 11 preview_paper = false; | 11 preview_paper = 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 |
| 37 lip_lines = 2; // [1:1:8] | 37 lip_lines = 2; // [1:1:8] |
| 38 // lip height in layers | 38 // lip height in layers |
| 39 lip_layers = 4; // [1:1:20] | 39 lip_layers = 4; // [1:1:20] |
| 40 // floor and lid top thickness in layers | 40 // floor and lid top thickness in layers |
| 41 floor_layers = 6; // [2:1:20] | 41 floor_layers = 6; // [2:1:20] |
| 42 // chamfer height in layers at the build plate edges of body and lid. each layer steps in by one layer height | |
| 43 chamfer_layers = 3; // [0:1:10] | |
| 42 | 44 |
| 43 /* [hinge] */ | 45 /* [hinge] */ |
| 44 // diameter of the filament used as hinge pin | 46 // diameter of the filament used as hinge pin |
| 45 filament_diameter = 1.75; // [1:.05:3] | 47 filament_diameter = 1.75; // [1:.05:3] |
| 46 // number of hinge knuckles. the body gets the outer ones | 48 // number of hinge knuckles. the body gets the outer ones |
| 76 wall_t = wall_lines*lw; | 78 wall_t = wall_lines*lw; |
| 77 // lid wall part that overlaps the lip from outside | 79 // lid wall part that overlaps the lip from outside |
| 78 skirt_t = (wall_lines - lip_lines)*lw; | 80 skirt_t = (wall_lines - lip_lines)*lw; |
| 79 lip_h = lip_layers*lh; | 81 lip_h = lip_layers*lh; |
| 80 floor_t = floor_layers*lh; | 82 floor_t = floor_layers*lh; |
| 83 chamfer_h = chamfer_layers*lh; | |
| 81 out_x = inner_depth + 2*wall_t; | 84 out_x = inner_depth + 2*wall_t; |
| 82 out_y = inner_width + 2*wall_t; | 85 out_y = inner_width + 2*wall_t; |
| 83 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon); | 86 edge_r = min(edge_radius, min(out_x, out_y)/2 - epsilon); |
| 84 | 87 |
| 85 // heights. the seam between body and lid sits on a layer boundary | 88 // heights. the seam between body and lid sits on a layer boundary |
| 133 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles"); | 136 assert(knuckle_l > 2*lw, "hinge knuckles too short, reduce hinge_knuckles"); |
| 134 assert(latch_width <= hinge_span, "latch wider than the box front"); | 137 assert(latch_width <= hinge_span, "latch wider than the box front"); |
| 135 assert(seam_z + knuckle_r + knuckle_u <= top_z, "lid too low for the hinge knuckles"); | 138 assert(seam_z + knuckle_r + knuckle_u <= top_z, "lid too low for the hinge knuckles"); |
| 136 assert(latch_z + knuckle_r + knuckle_u <= top_z, "lid too low for the latch knuckles"); | 139 assert(latch_z + knuckle_r + knuckle_u <= top_z, "lid too low for the latch knuckles"); |
| 137 assert(lid_h > floor_t + lip_h + lh, "lid too low for the lip"); | 140 assert(lid_h > floor_t + lip_h + lh, "lid too low for the lip"); |
| 141 assert(chamfer_h <= floor_t, "chamfer higher than the floor"); | |
| 138 | 142 |
| 139 // lid sweep over a centred paper stack: radius of the lowest lid ceiling | 143 // lid sweep over a centred paper stack: radius of the lowest lid ceiling |
| 140 // point over the paper minus radius of the paper's front top corner | 144 // point over the paper minus radius of the paper's front top corner |
| 141 sweep_margin = | 145 sweep_margin = |
| 142 norm([hinge_x + inner_depth/2, lip_h + lh]) | 146 norm([hinge_x + inner_depth/2, lip_h + lh]) |
| 143 - norm([hinge_x + paper_size/2, floor_t + paper_size - seam_z]); | 147 - norm([hinge_x + paper_size/2, floor_t + paper_size - seam_z]); |
| 144 | 148 |
| 145 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions"); | 149 echo("wall thickness", wall_t, "mm", wall_lines, "extrusions"); |
| 146 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm"); | 150 echo("lip thickness", wall_t - skirt_t - cl, "mm, height", lip_h, "mm"); |
| 147 echo("outer size", out_x, out_y, top_z, "mm"); | 151 echo("outer size", out_x, out_y, top_z, "mm"); |
| 152 echo("chamfer", chamfer_h, "mm", chamfer_layers, "layers"); | |
| 148 echo("body height", seam_z, "mm, lid height", lid_h, "mm"); | 153 echo("body height", seam_z, "mm, lid height", lid_h, "mm"); |
| 149 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm"); | 154 echo("pin hole", pin_d, "mm, knuckle diameter", 2*knuckle_r, "mm"); |
| 150 echo("hinge knuckle length", knuckle_l, "mm"); | 155 echo("hinge knuckle length", knuckle_l, "mm"); |
| 151 echo("latch plate outer face", plate_u + plate_t, "mm from the front"); | 156 echo("latch plate outer face", plate_u + plate_t, "mm from the front"); |
| 152 echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); | 157 echo("latch hook reaches", hook_a, "degrees past the bar bottom, detent", _detent(hook_a), "mm"); |
| 154 | 159 |
| 155 // rounded box outline, inset by d | 160 // rounded box outline, inset by d |
| 156 module _outline(d) { | 161 module _outline(d) { |
| 157 r = max(edge_r - d, 0); | 162 r = max(edge_r - d, 0); |
| 158 offset(r=r) square([out_x - 2*d - 2*r, out_y - 2*d - 2*r], center=true); | 163 offset(r=r) square([out_x - 2*d - 2*r, out_y - 2*d - 2*r], center=true); |
| 164 } | |
| 165 | |
| 166 // outer box shape of height h, the bottom edge chamfered in steps of one | |
| 167 // layer, each step inset by one layer height | |
| 168 module _block(h) { | |
| 169 for (i = [0:1:chamfer_layers - 1]) | |
| 170 translate([0, 0, i*lh]) linear_extrude(lh + epsilon) _outline((chamfer_layers - i)*lh); | |
| 171 translate([0, 0, chamfer_h]) linear_extrude(h - chamfer_h) _outline(0); | |
| 159 } | 172 } |
| 160 | 173 |
| 161 // extrude a 2d profile drawn in x/z between y0 and y1 | 174 // extrude a 2d profile drawn in x/z between y0 and y1 |
| 162 module _yslab(y0, y1) { | 175 module _yslab(y0, y1) { |
| 163 translate([0, y1, 0]) rotate([90, 0, 0]) linear_extrude(y1 - y0) children(); | 176 translate([0, y1, 0]) rotate([90, 0, 0]) linear_extrude(y1 - y0) children(); |
| 201 } | 214 } |
| 202 } | 215 } |
| 203 | 216 |
| 204 difference() { | 217 difference() { |
| 205 union() { | 218 union() { |
| 206 linear_extrude(seam_z) _outline(0); | 219 _block(seam_z); |
| 207 translate([0, 0, seam_z - epsilon]) | 220 translate([0, 0, seam_z - epsilon]) |
| 208 linear_extrude(lip_h + epsilon) | 221 linear_extrude(lip_h + epsilon) |
| 209 difference() { | 222 difference() { |
| 210 _outline(skirt_t + cl); | 223 _outline(skirt_t + cl); |
| 211 _outline(wall_t); | 224 _outline(wall_t); |
| 234 } | 247 } |
| 235 } | 248 } |
| 236 | 249 |
| 237 difference() { | 250 difference() { |
| 238 union() { | 251 union() { |
| 239 translate([0, 0, seam_z]) linear_extrude(lid_h) _outline(0); | 252 translate([0, 0, top_z]) mirror([0, 0, 1]) _block(lid_h); |
| 240 for (i = [1:2:hinge_knuckles - 1]) | 253 for (i = [1:2:hinge_knuckles - 1]) |
| 241 _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) | 254 _back() _yslab(_knuckle_y0(i), _knuckle_y0(i) + knuckle_l) |
| 242 _knuckle(seam_z, seam_z + cl); | 255 _knuckle(seam_z, seam_z + cl); |
| 243 for (y0 = latch_outer_y0) | 256 for (y0 = latch_outer_y0) |
| 244 _front() _yslab(y0, y0 + latch_slot) _knuckle(latch_z, seam_z + cl); | 257 _front() _yslab(y0, y0 + latch_slot) _knuckle(latch_z, seam_z + cl); |
