From b871a2f8bd24656fbf5387dc0c373d4f1b8ffd9e Mon Sep 17 00:00:00 2001 From: zhengwr Date: Sat, 4 Jul 2026 15:05:32 +0800 Subject: [PATCH] Portability: Blender/ODA discovery via env > PATH > macOS default The two hardcoded macOS paths in code become last-resort defaults: - build_showcase_variants: env BLENDER > shutil.which("blender") > app bundle - cad_dxf_report: env ODA_CONVERTER > shutil.which("ODAFileConverter") > app bundle (env override existed already; PATH lookup is new) Docs annotate the macOS example paths with the discovery order. Co-Authored-By: Claude Fable 5 --- SKILL.md | 4 ++-- references/pipeline.md | 6 +++++- scripts/build_showcase_variants.py | 9 +++++++++ scripts/cad_dxf_report.py | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/SKILL.md b/SKILL.md index a8c1e56..49fa91f 100644 --- a/SKILL.md +++ b/SKILL.md @@ -66,7 +66,7 @@ The pipeline is designed so a first pass either succeeds or STOPS at a loud gate 1. Prepare the CAD folder. - Work from a folder under the current workspace when possible. On macOS, avoid direct reads from `Downloads` if TCC blocks access; ask the user to move/copy the CAD folder into the workspace. - Preserve the original CAD folder. Put converted/intermediate files in `work/`. - - If DWG files are present, prefer `libredwg` `dwg2dxf` for batch conversion. Use ODA/QCAD/FreeCAD only as fallback — EXCEPT for drawings containing `3DSOLID`/ACIS entities: libredwg silently drops ACIS data (R2013+ stores it in the ACDSDATA section), so 3D-solid DWGs must go through ODA File Converter (`/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter ACAD2004 DXF 0 1 "*.dwg"`). ODA reports bad arguments via GUI dialogs, not stderr: both directories must exist as absolute paths, and a silent exit-0 with no output means a dialog is blocking on screen. + - If DWG files are present, prefer `libredwg` `dwg2dxf` for batch conversion. Use ODA/QCAD/FreeCAD only as fallback — EXCEPT for drawings containing `3DSOLID`/ACIS entities: libredwg silently drops ACIS data (R2013+ stores it in the ACDSDATA section), so 3D-solid DWGs must go through ODA File Converter (`/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter ACAD2004 DXF 0 1 "*.dwg"` — macOS path shown; discovery order everywhere is env `ODA_CONVERTER` > `ODAFileConverter` on PATH > that macOS default). ODA reports bad arguments via GUI dialogs, not stderr: both directories must exist as absolute paths, and a silent exit-0 with no output means a dialog is blocking on screen. - No native converter available (Linux sandbox, no ODA/libredwg)? Use the WASM fallback: `npm install @mlightcad/libredwg-web`, then `node scripts/dwg_dump_json.mjs in.dwg dump.json --module-dir ` and `python3 scripts/dwgjson_to_dxf.py --json dump.json --out work/dxf_raw/file.dxf`. This carries LINE/PLINE/ARC/CIRCLE/ELLIPSE/SPLINE/TEXT/INSERT + full block definitions (enough for the extraction pipeline), but drops HATCH/DIMENSION/ATTRIB — do not use it to judge hatch-only column fills or attribute-held axis numbers. - Multi-discipline sets (建筑/结构/给排水/电气/暖通 subfolders): model from 建筑 (architecture) only by default; pull 结构 later just for columns/beams if the showcase needs structure. Never feed all disciplines into one extraction pass. @@ -99,7 +99,7 @@ The pipeline is designed so a first pass either succeeds or STOPS at a loud gate - Review the Markdown audit and SVG overlays. Iterate config if important geometry remains unclassified or hidden in high-risk entity types. 5. Generate Blender/GLB. - - Use Blender CLI: + - Use Blender CLI (macOS app-bundle path shown; on Linux/other, `blender` from PATH works — `build_showcase_variants.py` discovers it via env `BLENDER` > PATH > the macOS default): `/Applications/Blender.app/Contents/MacOS/Blender -b --python /scripts/build_blender_showcase.py -- --spec work/building_spec.json --out-dir outputs/ --name ` - Use Blender MCP only after the CLI artifact exists, for inspection, scene tuning, or interactive refinement. diff --git a/references/pipeline.md b/references/pipeline.md index 8c354b0..a90af26 100644 --- a/references/pipeline.md +++ b/references/pipeline.md @@ -236,12 +236,16 @@ Expected outputs: - `.png` - `model_metadata.json` -If Blender CLI fails, verify the path. On this machine, the app path has been: +If Blender CLI fails, verify the path. The macOS app-bundle path is: ```text /Applications/Blender.app/Contents/MacOS/Blender ``` +On Linux/other platforms use `blender` from PATH; scripts discover the +executable via env `BLENDER` > PATH > the macOS default, and ODA File +Converter via env `ODA_CONVERTER` > PATH > its macOS default. + ## 8. Web Showcase For a quick single-model preview, run: diff --git a/scripts/build_showcase_variants.py b/scripts/build_showcase_variants.py index 510872c..853faa8 100644 --- a/scripts/build_showcase_variants.py +++ b/scripts/build_showcase_variants.py @@ -8,6 +8,8 @@ Blender to produce GLBs. Its manifest is consumed by write_web_showcase.py. from __future__ import annotations import argparse +import shutil +import os import copy import json import subprocess @@ -38,6 +40,13 @@ VARIANTS = [ def default_blender() -> str: + """Blender executable: env BLENDER > PATH > macOS app-bundle default.""" + override = os.environ.get("BLENDER") + if override: + return override + found = shutil.which("blender") + if found: + return found return "/Applications/Blender.app/Contents/MacOS/Blender" diff --git a/scripts/cad_dxf_report.py b/scripts/cad_dxf_report.py index 70838cb..9222349 100755 --- a/scripts/cad_dxf_report.py +++ b/scripts/cad_dxf_report.py @@ -86,10 +86,13 @@ def run_dwg2dxf(source: Path, dest: Path) -> dict: def oda_converter() -> str | None: - """ODA File Converter path (env ODA_CONVERTER overrides the macOS default).""" + """ODA File Converter: env ODA_CONVERTER > PATH > macOS app-bundle default.""" override = os.environ.get("ODA_CONVERTER") if override: return override if Path(override).exists() else None + found = shutil.which("ODAFileConverter") + if found: + return found default = Path("/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter") return str(default) if default.exists() else None