Windows support: install-path probing + platform notes

- Blender discovery adds the Windows versioned install dir (Program Files/
  Blender Foundation/Blender */blender.exe); ODA adds Program Files/ODA
  (both still env > PATH first; shutil.which resolves .exe via PATHEXT)
- README cross-platform section: pathlib + explicit UTF-8 I/O + bytes-decoded
  subprocesses throughout; Windows advice (PYTHONUTF8=1, LongPathsEnabled,
  ODA as the primary DWG path since libredwg is rare there)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 15:10:44 +08:00
parent b871a2f8bd
commit a6856f903d
3 changed files with 17 additions and 1 deletions

View File

@@ -39,6 +39,8 @@ tools/cad-building-showcase/SKILL.md 并遵守其中 One-Shot Definition of Done
**运行依赖**:Python ≥3.10 + `ezdxf`(惯例装到 `pip install --target work/vendor ezdxf`)、`shapely`、`trimesh`、`matplotlib`;Node ≥18(`tools/compress.mjs`、无原生转换器时的 WASM DWG 兜底)。可选:libredwg(`dwg2dxf` 批量转换)、ODA File Converter(坏件/天正大图兜底,脚本自动调用)、Blender(高保真渲染分支)。 **运行依赖**:Python ≥3.10 + `ezdxf`(惯例装到 `pip install --target work/vendor ezdxf`)、`shapely`、`trimesh`、`matplotlib`;Node ≥18(`tools/compress.mjs`、无原生转换器时的 WASM DWG 兜底)。可选:libredwg(`dwg2dxf` 批量转换)、ODA File Converter(坏件/天正大图兜底,脚本自动调用)、Blender(高保真渲染分支)。
**跨平台**:脚本全用 pathlib + 显式 UTF-8 I/O + 子进程 bytes 解码,macOS/Linux/Windows 均可跑。工具发现顺序:Blender = env `BLENDER` → PATH → 平台安装默认(macOS 应用包 / Windows `Program Files\Blender Foundation`);ODA = env `ODA_CONVERTER` → PATH → 平台默认(Windows 含 `Program Files\ODA`)。Windows 建议:设 `PYTHONUTF8=1`(防重定向输出按 GBK 解码)、开启 LongPathsEnabled(中文长文件名的深层 work/ 目录可能触及 260 字符 MAX_PATH);Windows 上 libredwg 少见,DWG 转换以 ODA 为主路径。
## 用法 ## 用法
入口是 `SKILL.md`(操作手册):决策循环、One-Shot Definition of Done 七条门禁、天正图层方言预设、多栋厂区流程。核心链路: 入口是 `SKILL.md`(操作手册):决策循环、One-Shot Definition of Done 七条门禁、天正图层方言预设、多栋厂区流程。核心链路:

View File

@@ -8,6 +8,8 @@ Blender to produce GLBs. Its manifest is consumed by write_web_showcase.py.
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import sys
import glob
import shutil import shutil
import os import os
import copy import copy
@@ -40,13 +42,17 @@ VARIANTS = [
def default_blender() -> str: def default_blender() -> str:
"""Blender executable: env BLENDER > PATH > macOS app-bundle default.""" """Blender executable: env BLENDER > PATH > platform install defaults."""
override = os.environ.get("BLENDER") override = os.environ.get("BLENDER")
if override: if override:
return override return override
found = shutil.which("blender") found = shutil.which("blender")
if found: if found:
return found return found
if sys.platform == "win32":
hits = sorted(glob.glob(r"C:/Program Files/Blender Foundation/Blender */blender.exe"))
if hits:
return hits[-1]
return "/Applications/Blender.app/Contents/MacOS/Blender" return "/Applications/Blender.app/Contents/MacOS/Blender"

View File

@@ -4,6 +4,7 @@
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import glob
import fnmatch import fnmatch
import json import json
import os import os
@@ -93,6 +94,13 @@ def oda_converter() -> str | None:
found = shutil.which("ODAFileConverter") found = shutil.which("ODAFileConverter")
if found: if found:
return found return found
if sys.platform == "win32":
hits = sorted(
glob.glob(r"C:/Program Files/ODA/*/ODAFileConverter.exe")
+ glob.glob(r"C:/Program Files (x86)/ODA/*/ODAFileConverter.exe")
)
if hits:
return hits[-1]
default = Path("/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter") default = Path("/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter")
return str(default) if default.exists() else None return str(default) if default.exists() else None