comparison main.scad @ 9:4b89f95689a8

preview: turn the model so the front faces the default camera part_view turns the preview 90 degrees about z so the front faces -y. preview_cut now removes the +x half of the turned model, the right half seen from the front, which keeps the hinge and latch profiles in the cut face. Exports are not turned.
author ark
date 2026-11-17 12:37 +0100
parents ac8f2ecb6c18
children a7a1b12fd6bf
comparison
equal deleted inserted replaced
8:ac8f2ecb6c18 9:4b89f95689a8
1 // hinged box with filament hinge at the back and a hinged latch in front. 1 // hinged box with filament hinge at the back and a hinged latch in front.
2 // sized by its inner dimensions, e.g. for standing notepad paper. 2 // sized by its inner dimensions, e.g. for standing notepad paper.
3 // x runs front (-x) to back (+x), y left to right, z up. 3 // x runs front (-x) to back (+x), y left to right, z up.
4 // the preview turns the model 90 degrees so the front faces -y.
4 5
5 /* [part selection] */ 6 /* [part selection] */
6 // part to show or export 7 // part to show or export
7 part = "all"; // [all, body, lid, latch] 8 part = "all"; // [all, body, lid, latch]
8 // cut away the -y half in preview 9 // cut away the +x half in preview, the right half seen from the front
9 preview_cut = false; 10 preview_cut = false;
10 // show a content mockup in each cell in the assembly view 11 // show a content mockup in each cell in the assembly view
11 preview_content = false; 12 preview_content = false;
12 // show the filament pins and latch bar in the assembly view 13 // show the filament pins and latch bar in the assembly view
13 preview_hardware = false; 14 preview_hardware = false;
519 translate([-latch_x, 0, -latch_z]) color("orange") latch(); 520 translate([-latch_x, 0, -latch_z]) color("orange") latch();
520 } 521 }
521 if (preview_content && $preview) _content(); 522 if (preview_content && $preview) _content();
522 } 523 }
523 524
525 // in preview, turn the model so its front faces the default camera at -y,
526 // and with preview_cut remove the +x half, the right half seen from the
527 // front. exports stay unturned
524 module part_view() { 528 module part_view() {
525 cut_s = max(out_x/2 + latch_front_u, top_z) 529 cut_s = max(out_x/2 + latch_front_u, top_z)
526 + (preview_lid_angle > 0 ? out_x : 0) + 1; 530 + (preview_lid_angle > 0 ? out_x : 0) + 1;
527 if ($preview && preview_cut) 531 if ($preview)
528 difference() { 532 difference() {
529 children(); 533 rotate([0, 0, 90]) children();
530 translate([-cut_s, -cut_s, -cut_s]) cube([2*cut_s, cut_s, 2*cut_s]); 534 if (preview_cut) translate([0, -cut_s, -cut_s]) cube([cut_s, 2*cut_s, 2*cut_s]);
531 } 535 }
532 else 536 else
533 children(); 537 children();
534 } 538 }
535 539