Web FreeCAD does not implement OpenSCAD. Drop the module end to end instead of keeping a blocked or placeholder shell: - delete the parity-matrix row and regenerate the module registry (31 modules, OpenSCAD absent) - remove the OpenSCAD-only frontend modules (worker, facades, slice, mesh backend, desktop/preferences tasks) and strip the OpenSCAD branches from the dispatchers, shells, storage and router - neutralise the two shared owners that outlived the module: openscad-desktop-view -> scene-viewport (SceneViewport) and openscad-desktop-adapter -> scene-document (SceneDocument), so Part, Mesh and the other consumers keep working - drop the FreeCADWebOpenSCADRuntimeProbe target and FREECAD_WEB_ENABLE_OPENSCAD option from the kernel CMake; BUILD_OPENSCAD stays in the forced-off list - delete web/openscad.html, its Vite input, the kernel artifacts and the 17 OpenSCAD tool entry points AGENTS.md records the removal rule. tsc --noEmit is clean and grep -ri openscad web/src is empty. Also carry the Boost pthread guard: under Emscripten a plain -lpthread implies -sUSE_PTHREADS=1 and therewith --shared-memory, which the non-atomics VTK archives cannot link against. Validation NOT_RUN / PARTIAL_FAILED, Acceptance NOT_CLAIMED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
5.9 KiB
Python
99 lines
5.9 KiB
Python
#!/usr/bin/env python3
|
||
"""Visible Web FreeCAD 29-case teaching runner.
|
||
|
||
Python owns the lesson order and evidence ledger. The browser actions are
|
||
performed by the local Playwright helper so the user sees the real Web
|
||
FreeCAD page instead of a simulated animation.
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import json
|
||
import os
|
||
import subprocess
|
||
import sys
|
||
from datetime import datetime, timezone
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
HELPER = ROOT / "tools" / "web-freecad-29-case-tutor.mjs"
|
||
DEFAULT_ORIGIN = os.environ.get("FREECAD_BROWSER_ORIGIN", "http://127.0.0.1:5183")
|
||
CASES = [
|
||
("assembly", "Assembly", "Assembly", "创建装配、插入组件、检查关节和保存重开"),
|
||
("bim", "BIM", "BIM", "创建 BIM 关系/分组并检查错误恢复"),
|
||
("cam", "CAM", "CAM", "执行完整三轴刀路、导出和保存重开"),
|
||
("cloud", "Cloud", "Cloud", "执行云文档保存和恢复"),
|
||
("draft", "Draft", "Draft", "进入 Draft 并执行二维对象入口"),
|
||
("fem", "Fem", "Fem", "进入 FEM 并执行分析任务入口"),
|
||
("help", "Help", "Help", "打开帮助工作台和资源入口"),
|
||
("import", "Import", "Import", "进入专用格式导入入口"),
|
||
("inspection", "Inspection", "Inspection", "执行检查对象和报告入口"),
|
||
("jtreader", "JtReader", "JtReader", "打开 JT/Inventor 入口"),
|
||
("material", "Material", "Material", "读取和赋值材质"),
|
||
("measure", "Measure", "Measure", "执行质量属性和距离测量"),
|
||
("meshpart", "MeshPart", "MeshPart", "执行网格到形状转换入口"),
|
||
("partdesign", "PartDesign", "PartDesign", "创建 Body、Sketch、Pad、Pocket"),
|
||
("plot", "Plot", "Plot", "进入绘图和只读 API 入口"),
|
||
("points", "Points", "Points", "读取点数据并检查显示"),
|
||
("reverseengineering", "ReverseEngineering", "ReverseEngineering", "执行曲线/曲面反求入口"),
|
||
("robot", "Robot", "Robot", "执行机器人路径和回放入口"),
|
||
("sandbox", "Sandbox", "Sandbox", "执行 Sandbox 测试对象入口"),
|
||
("show", "Show", "Show", "执行显示/生命周期入口"),
|
||
("sketcher", "Sketcher", "Sketcher", "创建草图和约束入口"),
|
||
("spreadsheet", "Spreadsheet", "Spreadsheet", "创建表格、公式和 CSV 入口"),
|
||
("start", "Start", "Start", "打开启动页并进入工作台"),
|
||
("surface", "Surface", "Surface", "执行曲面创建/重算入口"),
|
||
("techdraw", "TechDraw", "TechDraw", "创建页面/视图并重算入口"),
|
||
("templatepymod", "TemplatePyMod", "TemplatePyMod", "执行模板模块示例入口"),
|
||
("test", "Test", "Test", "执行测试工作台入口"),
|
||
("tux", "Tux", "Tux", "打开 Tux 示例入口"),
|
||
]
|
||
|
||
|
||
def main() -> int:
|
||
parser = argparse.ArgumentParser(description="用可见 Chrome 逐案例教学运行 Web FreeCAD")
|
||
parser.add_argument("--origin", default=DEFAULT_ORIGIN, help="Web FreeCAD 发布地址")
|
||
parser.add_argument("--case", choices=[item[0] for item in CASES] + ["all"], default="all")
|
||
parser.add_argument("--headless", action="store_true", help="无桌面环境时使用无头 Chrome,仅用于验收")
|
||
parser.add_argument("--interactive", action="store_true", help="每个案例开始前暂停,按回车继续")
|
||
parser.add_argument("--pause", type=float, default=2.0, help="每个案例完成后保持页面的秒数")
|
||
parser.add_argument("--screenshot-dir", default="docs/current/29-case-tutor-20261011", help="截图和账本目录")
|
||
parser.add_argument("--list", action="store_true", help="只列出案例,不启动浏览器")
|
||
args = parser.parse_args()
|
||
if args.list:
|
||
for index, (case_id, module, _command, lesson) in enumerate(CASES, 1):
|
||
print(f"{index:02d} {case_id:18s} {module:18s} {lesson}")
|
||
return 0
|
||
selected = CASES if args.case == "all" else [next(item for item in CASES if item[0] == args.case)]
|
||
out_dir = ROOT / args.screenshot_dir
|
||
out_dir.mkdir(parents=True, exist_ok=True)
|
||
run_id = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
||
manifest = [{"index": i + 1, "id": c[0], "module": c[1], "command": c[2], "lesson": c[3]} for i, c in enumerate(selected)]
|
||
manifest_path = out_dir / f"manifest-{run_id}.json"
|
||
manifest_path.write_text(json.dumps({"schema": "freecad-web-29-case-tutor-manifest/v1", "origin": args.origin, "cases": manifest}, ensure_ascii=False, indent=2) + "\n")
|
||
print(f"Web FreeCAD 29-case tutor: {args.origin}")
|
||
print(f"本次案例数: {len(selected)},截图目录: {out_dir}")
|
||
results = []
|
||
for case in manifest:
|
||
if args.interactive:
|
||
input(f"\n[{case['index']:02d}/{len(manifest)}] {case['module']}:{case['lesson']}。按回车打开真实页面...")
|
||
command = ["node", str(HELPER), "--origin", args.origin, "--case-json", json.dumps(case, ensure_ascii=False), "--out-dir", str(out_dir), "--pause", str(args.pause)]
|
||
if args.headless:
|
||
command.append("--headless")
|
||
try:
|
||
completed = subprocess.run(command, cwd=ROOT, text=True, check=False)
|
||
results.append({"case": case, "exitCode": completed.returncode, "status": "passed" if completed.returncode == 0 else "failed"})
|
||
except OSError as exc:
|
||
results.append({"case": case, "status": "failed", "error": str(exc)})
|
||
if results[-1]["status"] != "passed":
|
||
print(f"案例失败:{case['module']},继续保留失败证据并进入下一个案例", file=sys.stderr)
|
||
result_path = out_dir / f"run-{run_id}.json"
|
||
result_path.write_text(json.dumps({"schema": "freecad-web-29-case-tutor-run/v1", "origin": args.origin, "runId": run_id, "results": results}, ensure_ascii=False, indent=2) + "\n")
|
||
passed = sum(item["status"] == "passed" for item in results)
|
||
print(f"完成:{passed}/{len(results)},账本:{result_path}")
|
||
return 0 if passed == len(results) else 1
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|