소스 검색

Add PART selector for per-part STL export at origin

PART="case" renders only the case, PART="cap" renders only the cap,
both at origin. PART="all" (default) keeps the existing preview scene.
Moved the cap's positional translate out of cable_cap() into the render
section so the module is origin-based and reusable for export.
ZiB 4 달 전
부모
커밋
86479ccc36
1개의 변경된 파일과 32개의 추가작업 그리고 26개의 파일을 삭제
  1. 32 26
      cable_cap.scad

+ 32 - 26
cable_cap.scad

@@ -40,6 +40,9 @@ CLIP_Y     = 0;     // preview: mm to remove from Y+ (0 = full model)
 SHOW_DISP  = true;
 SHOW_DISP  = true;
 SCREEN_EXPLODE    = 0;     // mm to pull display toward X+ in preview
 SCREEN_EXPLODE    = 0;     // mm to pull display toward X+ in preview
 
 
+// --- Output ---
+PART = "all";  // "all" = preview scene; "case" = case STL at origin; "cap" = cap STL at origin
+
 // --- Slip-Fit Cap (X+ end) ---
 // --- Slip-Fit Cap (X+ end) ---
 SHOW_CAP    = true;   // show cap in preview
 SHOW_CAP    = true;   // show cap in preview
 CAP_RIBS    = false;  // include retention ribs in cap
 CAP_RIBS    = false;  // include retention ribs in cap
@@ -50,7 +53,7 @@ CAP_ENGAGE  = CAP_PAD + 6.0;   // sleeve engagement length over case exterior (X
 CAP_WALL    = 1.5;   // sleeve and end-wall thickness
 CAP_WALL    = 1.5;   // sleeve and end-wall thickness
 CAP_TOL     = 0.2;   // per-side slip clearance between bore and case exterior
 CAP_TOL     = 0.2;   // per-side slip clearance between bore and case exterior
 CAP_BEVEL   = 1.0;   // chamfer size on X+ face edges to guide cap onto case
 CAP_BEVEL   = 1.0;   // chamfer size on X+ face edges to guide cap onto case
-CAP_EXPLODE = CAP_PAD + 0;     // preview: mm to pull cap away from case in X+ (0 = seated)
+CAP_EXPLODE = CAP_PAD + 10;     // preview: mm to pull cap away from case in X+ (0 = seated)
 
 
 // --- Magnetic Strip Locating Lip (rear face) ---
 // --- Magnetic Strip Locating Lip (rear face) ---
 MAG_L        = 1.772 * 25.4;   // strip length ≈ 45.01 mm
 MAG_L        = 1.772 * 25.4;   // strip length ≈ 45.01 mm
@@ -188,7 +191,6 @@ module cable_cap() {
     _cap_h   = _cap_bore_h + CAP_WALL;
     _cap_h   = _cap_bore_h + CAP_WALL;
     _cap_cy  = (_cap_bore_w + 2 * CAP_WALL) / 2;  // Y center of cap
     _cap_cy  = (_cap_bore_w + 2 * CAP_WALL) / 2;  // Y center of cap
 
 
-    translate([case_w - CAP_ENGAGE + CAP_EXPLODE, 0, 0]){
     union() {
     union() {
     difference() {
     difference() {
         // Outer shell: flat rectangle at open end, rounded rectangle at closed end
         // Outer shell: flat rectangle at open end, rounded rectangle at closed end
@@ -227,30 +229,34 @@ module cable_cap() {
         translate([-0.01, 0, _cap_bore_h + CAP_WALL - 0.01])
         translate([-0.01, 0, _cap_bore_h + CAP_WALL - 0.01])
             cube([0.01, case_d, 0.01]);
             cube([0.01, case_d, 0.01]);
     }
     }
-    }}
-}
-
-color("#004B49")
-    intersection() {
-        epd_case();
-        cube([case_w + 1,
-              ($preview && CLIP_Y > 0) ? max(0.01, case_d - CLIP_Y) : case_d + 1,
-              ($preview && CLIP_Z > 0) ? max(0.01, case_h - CLIP_Z) : case_h + 1]);
     }
     }
+}
 
 
-if ($preview && SHOW_DISP)
-    translate([WALL + TOL + SCREEN_EXPLODE, WALL + TOL, WALL])
-        EPD213B();
-
-if (SHOW_CAP)
-    color("#1A3A6B")
-        intersection() {
-            cable_cap();
-            translate([0, 0, -(CAP_TOL + CAP_WALL)])
-                cube([case_w + CAP_WALL + CAP_ENGAGE + CAP_EXPLODE + 1,
-                      ($preview && CLIP_Y > 0)
-                          ? max(0.01, case_d - CLIP_Y)
-                          : case_d + 1,
-                      case_h + 2*(CAP_TOL + CAP_WALL) + 1]);
-        }
+_clip = [case_w + 1,
+         ($preview && CLIP_Y > 0) ? max(0.01, case_d - CLIP_Y) : case_d + 1,
+         ($preview && CLIP_Z > 0) ? max(0.01, case_h - CLIP_Z) : case_h + 1];
+
+if (PART == "case") {
+    epd_case();
+} else if (PART == "cap") {
+    cable_cap();
+} else {
+    color("#004B49")
+        intersection() { epd_case(); cube(_clip); }
+
+    if ($preview && SHOW_DISP)
+        translate([WALL + TOL + SCREEN_EXPLODE, WALL + TOL, WALL])
+            EPD213B();
+
+    if (SHOW_CAP)
+        color("#1A3A6B")
+            translate([case_w - CAP_ENGAGE + CAP_EXPLODE, 0, 0])
+                intersection() {
+                    cable_cap();
+                    translate([0, 0, -(CAP_TOL + CAP_WALL)])
+                        cube([CAP_ENGAGE + CAP_WALL + 1,
+                              _clip[1],
+                              case_h + 2*(CAP_TOL + CAP_WALL) + 1]);
+                }
+}