comparison main.scad @ 3:f5ff6f1a5454

better decal handling
author ark
date 2026-11-03 13:54 +0100
parents fe29ace8155e
children 4836a7408849
comparison
equal deleted inserted replaced
2:fe29ace8155e 3:f5ff6f1a5454
51 seal_magnets = false; 51 seal_magnets = false;
52 52
53 /* [two-colour] */ 53 /* [two-colour] */
54 // split into body and decal, for a filament change on a single-colour printer 54 // split into body and decal, for a filament change on a single-colour printer
55 two_colour = false; 55 two_colour = false;
56 // width of the decal band along the outline 56 // width of the decal band along the outline, on the face; it narrows by one layer height per layer
57 band_width = 4; // [.5:.1:20] 57 band_width = 4; // [.5:.1:20]
58 // decal thickness in layers, at most the glyph thickness less 2 layers
59 decal_layers = 2; // [1:1:10]
58 60
59 /* [washer] */ 61 /* [washer] */
60 // print the washers as part of the body, on the back of the glyph 62 // print the washers as part of the body, on the back of the glyph
61 washers_on_body = false; 63 washers_on_body = false;
62 // washer wall around the screw hole or magnet, in line widths 64 // washer wall around the screw hole or magnet, in line widths
81 83
82 // thicknesses 84 // thicknesses
83 glyph_t = glyph_layers * lh; 85 glyph_t = glyph_layers * lh;
84 backing_t = backing ? backing_layers * lh : 0; 86 backing_t = backing ? backing_layers * lh : 0;
85 total_t = glyph_t + backing_t; 87 total_t = glyph_t + backing_t;
86 decal_t = 2 * lh; // 2 layers 88 // decal layers, leaving at least 2 layers of body
89 decal_n = max(1, min(decal_layers, glyph_layers - 2));
90 decal_t = decal_n * lh;
91 // band width of the top decal layer
92 band_top = band_width - (decal_n - 1) * lh;
87 frame_t = lh; // 1 layer 93 frame_t = lh; // 1 layer
88 94
89 magnet = attachment == "magnet"; 95 magnet = attachment == "magnet";
90 96
91 // screw holes: 90 degree countersink, depth is half the diameter difference 97 // screw holes: 90 degree countersink, depth is half the diameter difference
156 if (magnet && seal_magnets) 162 if (magnet && seal_magnets)
157 echo(str("pause: insert the magnets after the layer ending at ", pause_z, " mm, layer ", 163 echo(str("pause: insert the magnets after the layer ending at ", pause_z, " mm, layer ",
158 round(pause_z / lh), washers_on_body ? " of the body" : " of the washer")); 164 round(pause_z / lh), washers_on_body ? " of the body" : " of the washer"));
159 if (magnet && seal_magnets && pocket_h > magnet_h + epsilon) 165 if (magnet && seal_magnets && pocket_h > magnet_h + epsilon)
160 echo(str("WARNING: pocket depth raised to ", pocket_h, " mm, whole layers")); 166 echo(str("WARNING: pocket depth raised to ", pocket_h, " mm, whole layers"));
167 if (two_colour) {
168 echo(str("decal: ", decal_n, " layers, ", decal_t, " mm, band ", band_width,
169 " mm on the face, ", band_top, " mm on the top layer"));
170 if (decal_n < decal_layers)
171 echo(str("WARNING: decal reduced to ", decal_n, " layers, glyph thickness less 2 layers"));
172 if (band_top < lw)
173 echo(str("WARNING: band on the top decal layer is ", band_top,
174 " mm, less than a line width"));
175 }
161 if (washer_set < washer_min) 176 if (washer_set < washer_min)
162 echo(str("WARNING: washer height raised to ", washer_min, " mm")); 177 echo(str("WARNING: washer height raised to ", washer_min, " mm"));
163 for (h = holes) if (h[1] < fit_r_req) 178 for (h = holes) if (h[1] < fit_r_req)
164 echo(str("WARNING: hole at ", h[0], ": largest circle radius ", h[1], " mm, ", 179 echo(str("WARNING: hole at ", h[0], ": largest circle radius ", h[1], " mm, ",
165 magnet ? "magnet" : "head", " plus wall needs ", fit_r_req, " mm")); 180 magnet ? "magnet" : "head", " plus wall needs ", fit_r_req, " mm"));
211 // Outline of all shown glyphs, placed for printing. 226 // Outline of all shown glyphs, placed for printing.
212 module _placed2d() { 227 module _placed2d() {
213 for (i = sel) _place() _glyph2d(i); 228 for (i = sel) _place() _glyph2d(i);
214 } 229 }
215 230
216 // Decal band: the outline minus the outline shrunk by the band width. 231 // Decal band of one layer: the outline minus the outline shrunk by the band
217 module _band2d() { 232 // width. The band narrows by one layer height per layer, so its inner edge
233 // slopes away from the body and the nozzle can reach the body's lower layers.
234 // i: decal layer, 0 on the bed.
235 module _band2d(i) {
218 difference() { 236 difference() {
219 _placed2d(); 237 _placed2d();
220 offset(r = -band_width) _placed2d(); 238 offset(r = -(band_width - i * lh)) _placed2d();
221 } 239 }
240 }
241
242 // Decal layers in print orientation, one slab per layer.
243 // e: downward extension of each slab, for subtracting from the body.
244 module _decal3d(e = 0) {
245 for (i = [0 : decal_n - 1])
246 translate([0, 0, i * lh - e]) linear_extrude(lh + e) _band2d(i);
222 } 247 }
223 248
224 // Screw holes and countersinks, opening towards the bed, through washers 249 // Screw holes and countersinks, opening towards the bed, through washers
225 // printed on the body. Nothing for magnets. 250 // printed on the body. Nothing for magnets.
226 module _holes() { 251 module _holes() {
257 if (backing) for (i = sel) _place() _backing2d(i); 282 if (backing) for (i = sel) _place() _backing2d(i);
258 else _placed2d(); 283 else _placed2d();
259 } 284 }
260 285
261 // Glyph body in print orientation, face on the bed. In two-colour mode the 286 // Glyph body in print orientation, face on the bed. In two-colour mode the
262 // decal band plus one line width is left out of the decal layers. Washers 287 // decal is left out of the decal layers. Washers
263 // printed on the body stand on its back, cut back to the outline of the back 288 // printed on the body stand on its back, cut back to the outline of the back
264 // so they do not overhang, with the magnet pockets at their top. 289 // so they do not overhang, with the magnet pockets at their top.
265 // frame: include the frame (two-colour mode only). 290 // frame: include the frame (two-colour mode only).
266 module body(frame = true) { 291 module body(frame = true) {
267 difference() { 292 difference() {
277 } 302 }
278 } 303 }
279 if (washers_on_body && magnet) 304 if (washers_on_body && magnet)
280 for (h = holes) translate([h[0].x, h[0].y, total_t + washer_h]) _pocket(); 305 for (h = holes) translate([h[0].x, h[0].y, total_t + washer_h]) _pocket();
281 _holes(); 306 _holes();
282 if (two_colour) 307 if (two_colour) _decal3d(epsilon);
283 translate([0, 0, -epsilon]) linear_extrude(decal_t + epsilon)
284 offset(delta = lw) _band2d();
285 } 308 }
286 if (two_colour && frame) _frame(); 309 if (two_colour && frame) _frame();
287 } 310 }
288 311
289 // Decal in print orientation: the band along the outline, with the frame. 312 // Decal in print orientation: the band along the outline, with the frame.
290 // frame: include the frame. 313 // frame: include the frame.
291 module decal(frame = true) { 314 module decal(frame = true) {
292 difference() { 315 difference() {
293 linear_extrude(decal_t) _band2d(); 316 _decal3d();
294 _holes(); 317 _holes();
295 } 318 }
296 if (frame) _frame(); 319 if (frame) _frame();
297 } 320 }
298 321
382 ? magnet 405 ? magnet
383 ? str(magnet_str, "_w", washer_wall_lines, "h", round(10 * washer_h)) 406 ? str(magnet_str, "_w", washer_wall_lines, "h", round(10 * washer_h))
384 : str(countersink ? "cs_" : "", "d", round(10 * screw_d), "w", washer_wall_lines, 407 : str(countersink ? "cs_" : "", "d", round(10 * screw_d), "w", washer_wall_lines,
385 "h", round(10 * washer_h), countersink ? str("c", round(10 * cs_washer)) : "") 408 "h", round(10 * washer_h), countersink ? str("c", round(10 * cs_washer)) : "")
386 : str(g_name, "_", layout == "glyph" ? str("g", glyph_index, "_") : "", 409 : str(g_name, "_", layout == "glyph" ? str("g", glyph_index, "_") : "",
387 two_colour ? "2c_" : "", backing ? "bk_" : "", 410 two_colour ? str("2cd", decal_n, "_") : "", backing ? "bk_" : "",
388 magnet ? (washers_on_body ? str(magnet_str, "_") : "mg_") 411 magnet ? (washers_on_body ? str(magnet_str, "_") : "mg_")
389 : countersink ? "cs_" : "", 412 : countersink ? "cs_" : "",
390 washers_on_body ? str("wh", round(10 * washer_h), "_") : "", 413 washers_on_body ? str("wh", round(10 * washer_h), "_") : "",
391 "s", round(10 * final_size), "a", round(print_angle), "t", glyph_layers), 414 "s", round(10 * final_size), "a", round(print_angle), "t", glyph_layers),
392 "_lw", round(100 * line_width), "lh", round(100 * layer_height), 415 "_lw", round(100 * line_width), "lh", round(100 * layer_height),