feat(carrier): 航空母舰 PartDesign 有头创建工具包与初学者教学

- 新数据链 web/teaching/cases/carrier-partdesign:20 件零件(spec.json 唯一来源)、
  内核建造器 parts/*.mjs、traces/FCStd/replay 全量产物;装配 20 插入 + 19 关节。
- 工具包 tools/carrier:catalog / preflight / create-part / create-assembly /
  create-all / list / self-test / README,按零件与装配拆分为独立工具。
- 共享驱动扩展 web/tools/cad-ui-rebuild:Loft/Pipe/Hole/Fillet/Chamfer/Mirrored/
  LinearPattern 交互,Reversed 复选框补齐;装配 saveAssemblyBundle 先 Accept 再保存。
- 教学:lessons.mjs 新增 carrier 组(环境课 + 20 件 + 装配),suite-runner 增加
  carrier-part/carrier-assembly,生成 carrier-toolkit.html 并接入 index 与控制台证据。

验证:20 件 210 步全部有头通过(P05 修复后 39640 m³;P06 回归 8/8);
装配 20/20 插入、19/19 关节、20 组件 0 畸形、0 mismatch;check:carrier、
check:reducer、check-console --live 全绿。

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 18:46:27 +08:00
parent b876ad5742
commit 87b2a6cb8a
335 changed files with 80492 additions and 5 deletions

View File

@@ -53,6 +53,13 @@
"reducer:assembly": "node ../tools/reducer/create-assembly.mjs",
"build:reducer-page": "node tools/teaching-console/build-reducer-page.mjs",
"check:reducer": "node ../tools/reducer/self-test.mjs && node tools/teaching-console/build-reducer-page.mjs --check && node tools/teaching-console/check-reducer-page.mjs",
"carrier:list": "node ../tools/carrier/list.mjs",
"carrier:part": "node ../tools/carrier/create-part.mjs",
"carrier:all": "node ../tools/carrier/create-all.mjs",
"carrier:assembly": "node ../tools/carrier/create-assembly.mjs",
"carrier:self-test": "node ../tools/carrier/self-test.mjs",
"build:carrier-page": "node tools/teaching-console/build-carrier-page.mjs",
"check:carrier": "node ../tools/carrier/self-test.mjs && node tools/teaching-console/build-carrier-page.mjs --check && node tools/teaching-console/check-carrier-page.mjs",
"prebuild": "npm run sync-show-python-family-fixture && npm run check:geometry-boundary",
"dev": "npm run sync-api-index && npm run sync-object-index && npm run sync-format-index && npm run sync-module-registry && npm run sync-part-tier2-adapter && npm run sync-partdesign-tier2-adapter && npm run sync-sketcher-tier2-adapter && npm run sync-techdraw-tier2-adapter && npm run sync-import-tier2-adapter && npm run sync-mesh-tier2-adapter && npm run sync-material-tier1-adapter && npm run sync-tier2-remainder && npm run sync-tier3-stateful && npm run sync-viewprovider-index && npm run sync-property-index && npm run sync-geometry-index && npm run sync-document-graph-index && npm run sync-capability-index && npm run sync-tier1-readonly && npm run sync-tier4-restricted && npm run sync-api-adapter-fill && npm run sync-format-extensions && npm run sync-kernel && npm run sync-release-manifest && vite --host 0.0.0.0",
"build": "npm run sync-api-index && npm run sync-object-index && npm run sync-format-index && npm run sync-module-registry && npm run sync-part-tier2-adapter && npm run sync-partdesign-tier2-adapter && npm run sync-sketcher-tier2-adapter && npm run sync-techdraw-tier2-adapter && npm run sync-import-tier2-adapter && npm run sync-mesh-tier2-adapter && npm run sync-material-tier1-adapter && npm run sync-tier2-remainder && npm run sync-tier3-stateful && npm run sync-viewprovider-index && npm run sync-property-index && npm run sync-geometry-index && npm run sync-document-graph-index && npm run sync-capability-index && npm run sync-tier1-readonly && npm run sync-tier4-restricted && npm run sync-api-adapter-fill && npm run sync-format-extensions && npm run sync-kernel && npm run sync-release-manifest && tsc --noEmit && vite build",

View File

@@ -0,0 +1,328 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>航空母舰 · PartDesign 有头创建工具(初学者)</title>
<style>
:root{--bg:#0f1419;--panel:#17212b;--panel2:#1b2733;--line:#2a3a45;--text:#dbe6ee;--muted:#93a6b3;--accent:#73c6d4;--ok:#7fc98b;--warn:#e0b15c;--bad:#e58a8a;color-scheme:dark}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.65 system-ui,-apple-system,"Segoe UI","Noto Sans CJK SC","Microsoft YaHei",sans-serif;overflow-wrap:break-word}
a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}
code,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
code{background:#0b1117;border:1px solid var(--line);border-radius:4px;padding:.1em .35em;font-size:.9em}
header.top{position:sticky;top:0;z-index:10;display:flex;gap:14px;align-items:center;padding:10px 18px;background:rgba(15,20,25,.94);border-bottom:1px solid var(--line);backdrop-filter:blur(6px)}
header.top .brand{font-weight:650}
header.top .spacer{flex:1}
main{max-width:1180px;margin:0 auto;padding:18px}
h1{font-size:22px;margin:6px 0}
h2{font-size:17px;margin:26px 0 10px;border-bottom:1px solid var(--line);padding-bottom:6px}
h3{font-size:15px;margin:0}
.lead{color:#c6d6e2}
.muted{color:var(--muted)}.small{font-size:12.5px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px 16px;margin:12px 0}
.pill{background:var(--panel2);border:1px solid var(--line);border-radius:999px;padding:1px 9px;font-size:12px;color:var(--muted)}
.parts{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:12px}
.part{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px 14px}
.part .head{display:flex;gap:8px;align-items:center;justify-content:space-between}
.part .meta{color:var(--muted);font-size:12.5px;margin:4px 0 8px}
.steps{margin:6px 0 10px 18px;padding:0;font-size:13px}
.steps li{margin:2px 0}
.steps .kind{display:inline-block;min-width:52px;color:var(--muted);font-size:11.5px;letter-spacing:.02em}
pre.cmd{background:#0b1117;border:1px solid var(--line);border-radius:8px;padding:8px 10px;font-size:12px;overflow:auto;white-space:pre-wrap;word-break:break-all}
.links{display:flex;gap:12px;flex-wrap:wrap;font-size:13px;margin-top:8px}
table{border-collapse:collapse;width:100%;font-size:13.5px}
th,td{border-bottom:1px solid var(--line);padding:6px 8px;text-align:left;vertical-align:top}
th{color:var(--muted);font-weight:500}
.note{border-left:3px solid var(--warn);padding:8px 12px;background:#1d1a12;border-radius:0 8px 8px 0;margin:10px 0}
@media (max-width:700px){.parts{grid-template-columns:1fr}main{padding:12px}}
@media print{header.top,.links,pre.cmd{display:none!important}}
</style>
</head>
<body>
<header class="top"><span class="brand">航空母舰 · PartDesign 有头创建工具</span><span class="spacer"></span>
<a href="index.html">教学中心</a><a href="console.html">教学控制台</a><a href="cases/carrier.html">旧版案例</a></header>
<main>
<h1>在真实界面里造一艘航空母舰</h1>
<p class="lead">20 个 PartDesign 零件,210 个界面步骤,分 12 个系统;每件都在真实浏览器里从草图开始点出来,最后装配成整舰(20 个链接 + 19 个固定关节)。舰长 333 m、甲板高 24 m,全部零件共用同一套舰体坐标。</p>
<div class="card">
<h2 style="margin-top:0">先做三件事</h2>
<ol>
<li>构建前端:<code>cd web &amp;&amp; npx vite build</code>(改过 <code>web/src</code> 之后必做)。</li>
<li>检查环境:<code>node tools/carrier/create-part.mjs P01 --dry</code> —— 只看前置,不启动浏览器。</li>
<li>建第一个零件:下面任意一张卡片里的命令,或直接打开<a href="console.html">教学控制台</a>点「开始」。</li>
</ol>
<p class="small muted">有头运行需要图形环境(<code>DISPLAY=:1</code>)与 Chrome。每次运行约 5–10 分钟,重型特征(甲板倒角、舰体放样)计算较久,界面会显示「计算中…」,等它结束即可。报告落在 <code>docs/current/carrier-partdesign-toolkit/runs/</code>,截图落在 <code>web/tools/carrier-partdesign-course/ui-stills/</code>。</p>
</div>
<div class="note"><strong>判定怎么读:</strong>通过 = 每一步都点到、最终体积与构建记录一致;产品失败(exit 1)= 界面建出的体积不对或有步骤没完成;前置失败(exit 2)= dist/内核/Chrome/DISPLAY/步骤文件缺失,此时还没开始点,不算产品问题。</div>
<div class="note"><strong>零件在船上是什么样:</strong>每件都按舰体坐标建模(X 向舰首为 +,z=24 m 为飞行甲板面),所以单独打开是零件、装配后自动就位,插装位姿是单位矩阵。改一个零件的尺寸,装配结果跟着变——这正是教学里要讲的“零件与装配同源”。</div>
<section class="group" id="group-hull-structure">
<h2>舰体结构 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P01">
<div class="head"><h3>P01 · 舰体</h3><span class="pill">10 步</span></div>
<div class="meta"><code>CarrierHull</code> · 记录体积 260,847 mm³ · 特征 Loft</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=-166.5</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=-150</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=-120</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=-60</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=0</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=60</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=110</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=145</code></li><li><span class="kind">草图</span><code>CarrierHull · 横剖面 x=166.5</code></li><li><span class="kind">特征</span><code>CarrierHull · 舰体放样</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P01</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-angled-deck">
<h2>斜角甲板 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P03">
<div class="head"><h3>P03 · 斜角甲板</h3><span class="pill">2 步</span></div>
<div class="meta"><code>CarrierAngledDeck</code> · 记录体积 6,912 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierAngledDeck · 斜角甲板平面</code></li><li><span class="kind">特征</span><code>CarrierAngledDeck · 斜角甲板</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P03</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-flight-deck">
<h2>飞行甲板 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P02">
<div class="head"><h3>P02 · 飞行甲板</h3><span class="pill">14 步</span></div>
<div class="meta"><code>CarrierDeck</code> · 记录体积 35,733 mm³ · 特征 Pad、Pocket、Chamfer</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierDeck · 甲板平面</code></li><li><span class="kind">特征</span><code>CarrierDeck · 甲板板</code></li><li><span class="kind">草图</span><code>CarrierDeck · 升降机井口 (-20, 26)</code></li><li><span class="kind">特征</span><code>CarrierDeck · 切除井口 WellPocket1</code></li><li><span class="kind">草图</span><code>CarrierDeck · 升降机井口 (-20, -26)</code></li><li><span class="kind">特征</span><code>CarrierDeck · 切除井口 WellPocket2</code></li><li><span class="kind">草图</span><code>CarrierDeck · 升降机井口 (-62, 26)</code></li><li><span class="kind">特征</span><code>CarrierDeck · 切除井口 WellPocket3</code></li><li><span class="kind">草图</span><code>CarrierDeck · 升降机井口 (-62, -26)</code></li><li><span class="kind">特征</span><code>CarrierDeck · 切除井口 WellPocket4</code></li><li><span class="kind">修整</span><code>CarrierDeck · 井口边缘倒角</code></li><li><span class="kind">草图</span><code>CarrierDeck · 系留桩平面</code></li><li><span class="kind">特征</span><code>CarrierDeck · 系留桩</code></li><li><span class="kind">阵列/镜像</span><code>CarrierDeck · 系留桩阵列</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P02</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-island">
<h2>舰岛上层建筑 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P04">
<div class="head"><h3>P04 · 舰岛</h3><span class="pill">11 步</span></div>
<div class="meta"><code>CarrierIsland</code> · 记录体积 10,658 mm³ · 特征 Pad、Chamfer</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierIsland · IslandBase 平面 z=24</code></li><li><span class="kind">特征</span><code>CarrierIsland · 塔体 IslandBase</code></li><li><span class="kind">草图</span><code>CarrierIsland · IslandTower 平面 z=36</code></li><li><span class="kind">特征</span><code>CarrierIsland · 塔体 IslandTower</code></li><li><span class="kind">草图</span><code>CarrierIsland · IslandBridge 平面 z=46</code></li><li><span class="kind">特征</span><code>CarrierIsland · 塔体 IslandBridge</code></li><li><span class="kind">草图</span><code>CarrierIsland · 烟囱平面</code></li><li><span class="kind">特征</span><code>CarrierIsland · 烟囱</code></li><li><span class="kind">草图</span><code>CarrierIsland · 桅杆截面</code></li><li><span class="kind">特征</span><code>CarrierIsland · 桅杆</code></li><li><span class="kind">修整</span><code>CarrierIsland · 舰桥顶倒角</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P04</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-hangar">
<h2>机库 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P05">
<div class="head"><h3>P05 · 机库</h3><span class="pill">4 步</span></div>
<div class="meta"><code>CarrierHangar</code> · 记录体积 39,640 mm³ · 特征 Pad、Pocket</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierHangar · 机库外壳平面</code></li><li><span class="kind">特征</span><code>CarrierHangar · 机库外壳</code></li><li><span class="kind">草图</span><code>CarrierHangar · 机库内腔平面</code></li><li><span class="kind">特征</span><code>CarrierHangar · 掏空内腔</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P05</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-aircraft-handling">
<h2>航空保障(升降机/弹射器/拦阻索) <span class="muted small">3 件</span></h2>
<div class="parts"><article class="part" id="P06">
<div class="head"><h3>P06 · 升降机</h3><span class="pill">8 步</span></div>
<div class="meta"><code>CarrierElevators</code> · 记录体积 1,008 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierElevators · 升降机平台 (-20, 26)</code></li><li><span class="kind">特征</span><code>CarrierElevators · 升降机平台</code></li><li><span class="kind">草图</span><code>CarrierElevators · 升降机平台 (-20, -26)</code></li><li><span class="kind">特征</span><code>CarrierElevators · 升降机平台</code></li><li><span class="kind">草图</span><code>CarrierElevators · 升降机平台 (-62, 26)</code></li><li><span class="kind">特征</span><code>CarrierElevators · 升降机平台</code></li><li><span class="kind">草图</span><code>CarrierElevators · 升降机平台 (-62, -26)</code></li><li><span class="kind">特征</span><code>CarrierElevators · 升降机平台</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P06</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P07">
<div class="head"><h3>P07 · 弹射器</h3><span class="pill">8 步</span></div>
<div class="meta"><code>CarrierCatapults</code> · 记录体积 347 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierCatapults · 弹射轨道 (118, 14)</code></li><li><span class="kind">特征</span><code>CarrierCatapults · 弹射轨道</code></li><li><span class="kind">草图</span><code>CarrierCatapults · 弹射轨道 (118, -14)</code></li><li><span class="kind">特征</span><code>CarrierCatapults · 弹射轨道</code></li><li><span class="kind">草图</span><code>CarrierCatapults · 弹射轨道 (8, 24)</code></li><li><span class="kind">特征</span><code>CarrierCatapults · 弹射轨道</code></li><li><span class="kind">草图</span><code>CarrierCatapults · 弹射轨道 (-30, -28)</code></li><li><span class="kind">特征</span><code>CarrierCatapults · 弹射轨道</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P07</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P08">
<div class="head"><h3>P08 · 拦阻索</h3><span class="pill">8 步</span></div>
<div class="meta"><code>CarrierArrestorWires</code> · 记录体积 25 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierArrestorWires · 拦阻索 x=-150</code></li><li><span class="kind">特征</span><code>CarrierArrestorWires · 拦阻索</code></li><li><span class="kind">草图</span><code>CarrierArrestorWires · 拦阻索 x=-144</code></li><li><span class="kind">特征</span><code>CarrierArrestorWires · 拦阻索</code></li><li><span class="kind">草图</span><code>CarrierArrestorWires · 拦阻索 x=-138</code></li><li><span class="kind">特征</span><code>CarrierArrestorWires · 拦阻索</code></li><li><span class="kind">草图</span><code>CarrierArrestorWires · 拦阻索 x=-132</code></li><li><span class="kind">特征</span><code>CarrierArrestorWires · 拦阻索</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P08</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-sensors">
<h2>雷达与传感 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P09">
<div class="head"><h3>P09 · 相控阵雷达</h3><span class="pill">6 步</span></div>
<div class="meta"><code>CarrierRadar</code> · 记录体积 69 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierRadar · 雷达基座截面</code></li><li><span class="kind">特征</span><code>CarrierRadar · 雷达基座</code></li><li><span class="kind">草图</span><code>CarrierRadar · 阵面草图</code></li><li><span class="kind">特征</span><code>CarrierRadar · 相控阵面</code></li><li><span class="kind">草图</span><code>CarrierRadar · 阵面支架截面</code></li><li><span class="kind">特征</span><code>CarrierRadar · 阵面支架</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P09</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-weapons">
<h2>近防武器 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P10">
<div class="head"><h3>P10 · 近防炮</h3><span class="pill">8 步</span></div>
<div class="meta"><code>CarrierCiws</code> · 记录体积 56 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierCiws · 炮座截面</code></li><li><span class="kind">特征</span><code>CarrierCiws · 炮座</code></li><li><span class="kind">草图</span><code>CarrierCiws · 炮塔壳体</code></li><li><span class="kind">特征</span><code>CarrierCiws · 炮塔壳体</code></li><li><span class="kind">草图</span><code>CarrierCiws · 炮管截面 y=-0.7</code></li><li><span class="kind">特征</span><code>CarrierCiws · 炮管</code></li><li><span class="kind">草图</span><code>CarrierCiws · 炮管截面 y=0.7</code></li><li><span class="kind">特征</span><code>CarrierCiws · 炮管</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P10</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-air-fighter">
<h2>舰载战斗机 <span class="muted small">6 件</span></h2>
<div class="parts"><article class="part" id="P11">
<div class="head"><h3>P11 · 舰载战斗机 A</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterA</code> · 记录体积 83 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterA · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterA · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterA · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterA · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterA · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterA · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterA · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterA · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterA · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterA · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterA · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterA · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterA · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P11</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P12">
<div class="head"><h3>P12 · 舰载战斗机 B</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterB</code> · 记录体积 88 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterB · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterB · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterB · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterB · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterB · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterB · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterB · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterB · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterB · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterB · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterB · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterB · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterB · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P12</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P13">
<div class="head"><h3>P13 · 舰载战斗机 C</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterC</code> · 记录体积 74 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterC · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterC · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterC · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterC · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterC · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterC · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterC · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterC · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterC · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterC · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterC · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterC · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterC · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P13</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P14">
<div class="head"><h3>P14 · 舰载战斗机 D</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterD</code> · 记录体积 92 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterD · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterD · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterD · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterD · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterD · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterD · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterD · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterD · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterD · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterD · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterD · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterD · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterD · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P14</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P15">
<div class="head"><h3>P15 · 舰载战斗机 E</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterE</code> · 记录体积 79 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterE · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterE · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterE · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterE · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterE · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterE · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterE · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterE · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterE · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterE · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterE · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterE · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterE · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P15</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P16">
<div class="head"><h3>P16 · 舰载战斗机 F</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierFighterF</code> · 记录体积 85 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierFighterF · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierFighterF · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierFighterF · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierFighterF · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterF · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterF · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterF · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierFighterF · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierFighterF · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierFighterF · 垂尾</code></li><li><span class="kind">图元</span><code>CarrierFighterF · 座舱盖</code></li><li><span class="kind">草图</span><code>CarrierFighterF · 尾喷口截面</code></li><li><span class="kind">特征</span><code>CarrierFighterF · 尾喷口</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P16</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-air-awacs">
<h2>舰载预警机 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P17">
<div class="head"><h3>P17 · 舰载预警机</h3><span class="pill">21 步</span></div>
<div class="meta"><code>CarrierAwacs</code> · 记录体积 255 mm³ · 特征 Revolution、Pad、Mirrored</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierAwacs · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 右机翼平面</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 右机翼</code></li><li><span class="kind">阵列/镜像</span><code>CarrierAwacs · 左机翼镜像</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 桨舱截面 y=4.2</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 桨舱</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 桨舱截面 y=8.6</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 桨舱</code></li><li><span class="kind">阵列/镜像</span><code>CarrierAwacs · 桨舱镜像</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 平尾平面</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 平尾</code></li><li><span class="kind">阵列/镜像</span><code>CarrierAwacs · 平尾镜像</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 垂尾平面</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 垂尾</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 旋罩支柱截面 x=-2.4</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 旋罩支柱</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 旋罩支柱截面 x=2.4</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 旋罩支柱</code></li><li><span class="kind">草图</span><code>CarrierAwacs · 旋罩截面</code></li><li><span class="kind">特征</span><code>CarrierAwacs · 雷达旋罩</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P17</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-air-rotor">
<h2>舰载直升机 <span class="muted small">2 件</span></h2>
<div class="parts"><article class="part" id="P18">
<div class="head"><h3>P18 · 舰载直升机 A</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierHelicopterA</code> · 记录体积 48 mm³ · 特征 Revolution、Pad、PolarPattern</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierHelicopterA · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierHelicopterA · 尾梁截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 尾梁</code></li><li><span class="kind">草图</span><code>CarrierHelicopterA · 尾鳍平面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 尾鳍</code></li><li><span class="kind">草图</span><code>CarrierHelicopterA · 尾桨截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 尾桨</code></li><li><span class="kind">草图</span><code>CarrierHelicopterA · 旋翼轴截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 旋翼轴</code></li><li><span class="kind">草图</span><code>CarrierHelicopterA · 主旋翼叶片</code></li><li><span class="kind">特征</span><code>CarrierHelicopterA · 主旋翼叶片</code></li><li><span class="kind">阵列/镜像</span><code>CarrierHelicopterA · 四叶旋翼</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P18</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article><article class="part" id="P19">
<div class="head"><h3>P19 · 舰载直升机 B</h3><span class="pill">13 步</span></div>
<div class="meta"><code>CarrierHelicopterB</code> · 记录体积 48 mm³ · 特征 Revolution、Pad、PolarPattern</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierHelicopterB · 机身半剖</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 机身回转</code></li><li><span class="kind">草图</span><code>CarrierHelicopterB · 尾梁截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 尾梁</code></li><li><span class="kind">草图</span><code>CarrierHelicopterB · 尾鳍平面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 尾鳍</code></li><li><span class="kind">草图</span><code>CarrierHelicopterB · 尾桨截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 尾桨</code></li><li><span class="kind">草图</span><code>CarrierHelicopterB · 旋翼轴截面</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 旋翼轴</code></li><li><span class="kind">草图</span><code>CarrierHelicopterB · 主旋翼叶片</code></li><li><span class="kind">特征</span><code>CarrierHelicopterB · 主旋翼叶片</code></li><li><span class="kind">阵列/镜像</span><code>CarrierHelicopterB · 四叶旋翼</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P19</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section><section class="group" id="group-markings">
<h2>甲板标线 <span class="muted small">1 件</span></h2>
<div class="parts"><article class="part" id="P20">
<div class="head"><h3>P20 · 甲板标线</h3><span class="pill">6 步</span></div>
<div class="meta"><code>CarrierMarkings</code> · 记录体积 26 mm³ · 特征 Pad</div>
<ol class="steps"><li><span class="kind">草图</span><code>CarrierMarkings · 甲板中心线</code></li><li><span class="kind">特征</span><code>CarrierMarkings · 中心线</code></li><li><span class="kind">草图</span><code>CarrierMarkings · 降落区边框</code></li><li><span class="kind">特征</span><code>CarrierMarkings · 降落区边框</code></li><li><span class="kind">草图</span><code>CarrierMarkings · 甲板边缘线</code></li><li><span class="kind">特征</span><code>CarrierMarkings · 甲板边缘线</code></li></ol>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-part.mjs P20</pre>
<div class="links">
<a href="console.html">在教学控制台运行</a>
<a href="cases/carrier.html">旧版案例(Part 工作台对照)</a>
</div>
</article></div>
</section>
<section class="group" id="assembly">
<h2>装配 <span class="muted small">1 艘</span></h2>
<article class="part">
<div class="head"><h3>CarrierAssembly · 20 件合成整舰</h3><span class="pill">20 插入 / 19 关节</span></div>
<div class="meta">新建装配文档「航空母舰」,逐个装载并插入 20 个零件链接,接地舰体,其余 19 件各建一个固定关节,最后求解并列出 BOM。</div>
<pre class="cmd">cd "/media/mes123456/Elements SE/WebFreeCAD/FreeCADWasmDev/working/FreeCAD" &amp;&amp; DISPLAY=:1 node tools/carrier/create-assembly.mjs</pre>
<div class="links"><a href="console.html">在教学控制台运行</a><a href="cases/carrier.html">旧版案例(Part 工作台 20 件)</a></div>
</article>
</section>
<section class="group" id="tools">
<h2>这套工具本身</h2>
<table>
<thead><tr><th>命令</th><th>作用</th></tr></thead>
<tbody>
<tr><td><code>node tools/carrier/list.mjs</code></td><td>列出 20 个零件、系统分组、步数与记录体积</td></tr>
<tr><td><code>node tools/carrier/create-part.mjs P02</code></td><td>有头重建一个零件(P 编号或 Document 名都行)</td></tr>
<tr><td><code>node tools/carrier/create-part.mjs P02 --dry</code></td><td>只做前置检查,不启动浏览器</td></tr>
<tr><td><code>node tools/carrier/create-part.mjs P02 --slow</code></td><td>放慢点击,适合边看边学</td></tr>
<tr><td><code>node tools/carrier/create-all.mjs --group air-fighter</code></td><td>按系统串行重建</td></tr>
<tr><td><code>node tools/carrier/create-all.mjs --all --keep-going</code></td><td>全部 20 件,出错继续</td></tr>
<tr><td><code>node tools/carrier/create-assembly.mjs --dry</code></td><td>装配前置检查(清单、回放、源文档、引擎)</td></tr>
<tr><td><code>node tools/carrier/create-assembly.mjs</code></td><td>真实界面装配整舰</td></tr>
<tr><td><code>node tools/carrier/self-test.mjs</code></td><td>无浏览器自测(目录、分组、参数校验、前置)</td></tr>
</tbody>
</table>
<p class="small muted">工具只做编排与前置检查;每一步的点击由共享引擎 <code>web/tools/cad-ui-rebuild/</code> 执行,构建记录来自 <code>web/teaching/cases/carrier-partdesign/out/replay/</code>,界面步骤来自 <code>web/tools/carrier-partdesign-course/out/ui-steps/</code>,装配清单来自 <code>assembly-spec.json</code>。文档一律写 OPFS,只有显式「下载」才落到本地。</p>
</section>
<section class="group" id="troubleshooting">
<h2>常见问题</h2>
<table>
<thead><tr><th>现象</th><th>原因与处理</th></tr></thead>
<tbody>
<tr><td>退出码 2,日志里有「前置缺失」</td><td>dist、内核产物、Chrome、DISPLAY 或步骤文件缺失。照提示修,或用 <code>--dry</code> 看全部检查项。</td></tr>
<tr><td>退出码 1,体积不一致</td><td>界面建出的几何与构建记录不同,是产品回归;报告里给出两边体积与相对误差。</td></tr>
<tr><td>某一步停住不动</td><td>重型特征(甲板倒角、舰体放样)计算可达数十秒,状态栏显示「计算中…」。工具会等树里出现新对象再继续,不要手动刷新。</td></tr>
<tr><td>看不到浏览器窗口</td><td>有头需要可用的 X 显示;在带图形界面的会话里用 <code>DISPLAY=:1</code> 启动。</td></tr>
<tr><td>页面打开是空白/旧版本</td><td>先 <code>cd web &amp;&amp; npx vite build</code>,工具会自动为构建好的 dist 起临时服务。</td></tr>
<tr><td>装配插入失败,提示源文档缺失</td><td>先跑完对应零件(<code>create-part</code>),把 <code>out/FCStd/&lt;Document&gt;.FCStd</code> 准备好;<code>create-assembly --dry</code> 会列出缺哪几份。</td></tr>
</tbody>
</table>
</section>
<p class="small muted" style="margin:26px 0 40px">本页由 <code>web/tools/teaching-console/build-carrier-page.mjs</code> 生成,请勿手改。</p>
</main>
</body>
</html>

View File

@@ -0,0 +1,425 @@
{
"schema": "freecad-web/carrier-toolkit/assembly-spec/v1",
"document": "CarrierAssembly",
"label": "航空母舰",
"groundDocument": "CarrierHull",
"note": "零件在各自文档里已按舰体坐标建模,插入用单位位姿;每个非接地零件用一个固定关节锚到父件(20 件 − 1 接地 = 19 个关节),避免出现悬空组件。",
"inserts": [
{
"sourceDocument": "CarrierHull",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierDeck",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierAngledDeck",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierIsland",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierHangar",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierElevators",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierCatapults",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierArrestorWires",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierRadar",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierCiws",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterA",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterB",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterC",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterD",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterE",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierFighterF",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierAwacs",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierHelicopterA",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierHelicopterB",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
},
{
"sourceDocument": "CarrierMarkings",
"sourceObject": "Body",
"position": [
0,
0,
0
],
"rotation": [
0,
0,
0,
1
]
}
],
"joints": [
{
"type": "Fixed",
"label": "飞行甲板 / 舰体",
"a": "CarrierDeck",
"b": "CarrierHull"
},
{
"type": "Fixed",
"label": "斜角甲板 / 飞行甲板",
"a": "CarrierAngledDeck",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰岛 / 飞行甲板",
"a": "CarrierIsland",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "机库 / 舰体",
"a": "CarrierHangar",
"b": "CarrierHull"
},
{
"type": "Fixed",
"label": "升降机 / 飞行甲板",
"a": "CarrierElevators",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "弹射器 / 飞行甲板",
"a": "CarrierCatapults",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "拦阻索 / 飞行甲板",
"a": "CarrierArrestorWires",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "相控阵雷达 / 舰岛",
"a": "CarrierRadar",
"b": "CarrierIsland"
},
{
"type": "Fixed",
"label": "近防炮 / 飞行甲板",
"a": "CarrierCiws",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 A / 飞行甲板",
"a": "CarrierFighterA",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 B / 飞行甲板",
"a": "CarrierFighterB",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 C / 飞行甲板",
"a": "CarrierFighterC",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 D / 飞行甲板",
"a": "CarrierFighterD",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 E / 飞行甲板",
"a": "CarrierFighterE",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载战斗机 F / 飞行甲板",
"a": "CarrierFighterF",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载预警机 / 飞行甲板",
"a": "CarrierAwacs",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载直升机 A / 飞行甲板",
"a": "CarrierHelicopterA",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "舰载直升机 B / 飞行甲板",
"a": "CarrierHelicopterB",
"b": "CarrierDeck"
},
{
"type": "Fixed",
"label": "甲板标线 / 飞行甲板",
"a": "CarrierMarkings",
"b": "CarrierDeck"
}
]
}

View File

@@ -0,0 +1,110 @@
#!/usr/bin/env node
/**
* Purpose: 由 assembly-spec.json 生成装配回放 out/replay/CarrierAssembly.json。
*
* 回放只记录“界面上做了什么、按什么参数做”:创建装配、打开 20 份源文档、
* 逐个插入链接、接地、求解、每个非接地零件一个固定关节、再求解、列 BOM。
* 组装脚本 web/tools/cad-ui-rebuild/assemble.mjs 直接读这份文件执行,
* 不在这里启动浏览器。
*
* 组件名由插入顺序决定:Component、Component001 …(与 FreeCAD 一致),
* 关节的 selection / references 全部引用这些名字。
*
* Usage: node build-assembly-replay.mjs [--dry]
* Output: out/replay/<document>.json(schema freecad-web-process-replay/v1, kind assembly)
*/
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const here = path.dirname(fileURLToPath(import.meta.url));
const specFile = path.join(here, "assembly-spec.json");
const spec = JSON.parse(fs.readFileSync(specFile, "utf8"));
const ASSEMBLY = "Assembly";
const dry = process.argv.includes("--dry");
const componentName = index => (index === 0 ? "Component" : `Component${String(index).padStart(3, "0")}`);
const componentOf = new Map(spec.inserts.map((insert, index) => [insert.sourceDocument, componentName(index)]));
const steps = [];
const push = (action, label, args, extra = {}) => steps.push({ step: steps.length + 1, label, action, seconds: 0, args, ...extra });
push("assembly.createRecompute", "create assembly", {
schema: "freecad-web-assembly/create-recompute/v1",
documentName: spec.document,
objectName: ASSEMBLY,
objectType: "Assembly::AssemblyObject",
label: spec.label,
});
push("Assembly_InsertLink", "open sources", {
documentId: spec.document, assembly: ASSEMBLY, action: "open",
files: spec.inserts.map(insert => ({ fileName: `${insert.sourceDocument}.FCStd` })),
});
for (const [index, insert] of spec.inserts.entries()) {
push("Assembly_InsertLink", `insert ${index + 1}/${spec.inserts.length} ${insert.sourceDocument}`, {
documentId: spec.document, assembly: ASSEMBLY, action: "insert",
sourceDocument: insert.sourceDocument, sourceObject: insert.sourceObject,
position: insert.position, rotation: insert.rotation, rigid: true,
}, { insert: { ...insert } });
}
push("Assembly_InsertLink", "accept insertion", {
documentId: spec.document, assembly: ASSEMBLY, action: "accept", selection: [],
});
push("Assembly_ToggleGrounded", `ground ${spec.groundDocument}`, {
documentId: spec.document, assembly: ASSEMBLY, action: "accept",
selection: [{ documentId: spec.document, object: ASSEMBLY, subelements: [componentOf.get(spec.groundDocument)] }],
});
const solve = label => ({
documentId: spec.document, assembly: ASSEMBLY, action: "accept", selection: [],
});
push("Assembly_SolveAssembly", "solve at zero pose", solve("solve at zero pose"));
for (const joint of spec.joints) {
const a = componentOf.get(joint.a);
const b = componentOf.get(joint.b);
if (!a || !b) throw new Error(`joint ${joint.label} names a part that is not inserted: ${joint.a} / ${joint.b}`);
push(`Assembly_CreateJoint${joint.type ?? "Fixed"}`, `joint ${joint.label}`, {
documentId: spec.document, assembly: ASSEMBLY, action: "accept", label: joint.label,
preservePose: true,
selection: [{ documentId: spec.document, object: a }, { documentId: spec.document, object: b }],
references: [
{ documentId: spec.document, object: ASSEMBLY, subelements: [a] },
{ documentId: spec.document, object: ASSEMBLY, subelements: [b] },
],
});
}
push("Assembly_SolveAssembly", "solve", solve("solve"));
push("Assembly_CreateBom", "list BOM", { documentId: spec.document, assembly: ASSEMBLY, action: "list" });
const replay = {
schema: "freecad-web-process-replay/v1",
kind: "assembly",
document: spec.document,
assembly: "build-assembly-replay.mjs",
generatedAt: new Date().toISOString(),
totals: { seconds: 0 },
steps,
};
if (dry) {
console.log(JSON.stringify({
document: spec.document,
inserts: spec.inserts.length,
joints: spec.joints.length,
solves: steps.filter(step => step.action === "Assembly_SolveAssembly").length,
steps: steps.length,
}, null, 2));
process.exit(0);
}
const outFile = path.join(here, "out", "replay", `${spec.document}.json`);
fs.mkdirSync(path.dirname(outFile), { recursive: true });
fs.writeFileSync(outFile, `${JSON.stringify(replay, null, 2)}\n`);
console.log(JSON.stringify({ output: path.relative(process.cwd(), outFile), steps: steps.length,
inserts: spec.inserts.length, joints: spec.joints.length }, null, 2));

View File

@@ -0,0 +1,90 @@
#!/usr/bin/env node
// 航空母舰 PartDesign 建件入口。
//
// node web/teaching/cases/carrier-partdesign/build.mjs # 全部 20 件
// node web/teaching/cases/carrier-partdesign/build.mjs P02 # 单件(id 或 Document)
// node web/teaching/cases/carrier-partdesign/build.mjs Deck --dry # 只看摘要
// node web/teaching/cases/carrier-partdesign/build.mjs --subset # P01..P10 舰体部分
//
// Each document is written to out/FCStd/<Document>.FCStd (OPFS mirror first,
// then an evidence copy) and out/traces/<Document>.json. The replay stage reads
// only the trace, so a failed builder leaves a trace you can inspect instead of
// an empty out/replay entry.
import path from "node:path";
import fs from "node:fs";
import { fileURLToPath } from "node:url";
import { parts, partFor } from "./parts/index.mjs";
import { buildDocument, caseDir, outDir, useCaseOpfs } from "./lib/build.mjs";
const argv = process.argv.slice(2);
const flags = new Set(argv.filter(arg => arg.startsWith("--")));
const selectors = argv.filter(arg => !arg.startsWith("--"));
const SHIP = ["P01", "P02", "P03", "P04", "P05", "P06", "P07", "P08", "P09", "P10"];
function selected() {
if (selectors.length === 0) return flags.has("--subset") ? parts.filter(part => SHIP.includes(part.id)) : parts;
const found = selectors.map(key => {
const part = partFor(key) ?? parts.find(item => item.document.toLowerCase() === key.toLowerCase());
if (!part) {
console.error(`未知零件 ${key};可选:${parts.map(item => `${item.id} ${item.document}`).join(", ")}`);
process.exit(2);
}
return part;
});
return found;
}
function specIndex() {
const file = path.join(caseDir, "spec.json");
if (!fs.existsSync(file)) return new Map();
const spec = JSON.parse(fs.readFileSync(file, "utf8"));
return new Map(spec.parts.map(part => [part.document, part]));
}
async function main() {
useCaseOpfs();
const queue = selected();
const spec = specIndex();
const indexFile = path.join(outDir, "index.json");
const previous = fs.existsSync(indexFile) ? JSON.parse(fs.readFileSync(indexFile, "utf8")) : { documents: {} };
const results = [];
let failed = 0;
for (const part of queue) {
const entry = spec.get(part.document) ?? {};
process.stdout.write(`▶ ${part.id} ${part.document} ${entry.title ?? ""}\n`);
try {
const summary = await buildDocument(part, { dry: flags.has("--dry") });
const volume = Number(summary.volume);
console.log(
` ✓ ${summary.steps} 步 · ${summary.seconds}s · 体积 ${Number.isFinite(volume) ? `${volume.toFixed(3)} m³` : "n/a"} · ${summary.fcstd}`,
);
results.push({ id: part.id, title: entry.title ?? null, system: entry.system ?? null, ...summary });
previous.documents[part.document] = {
id: part.id, title: entry.title ?? null, system: entry.system ?? null,
steps: summary.steps, volume: summary.volume, bounds: summary.bounds,
seconds: summary.seconds, fcstd: summary.fcstd, builtAt: new Date().toISOString(),
};
} catch (error) {
failed += 1;
console.error(` ✗ ${part.document}: ${error?.message ?? error}`);
if (!flags.has("--dry")) console.error(error?.stack ?? "");
}
}
fs.mkdirSync(outDir, { recursive: true });
fs.writeFileSync(indexFile, `${JSON.stringify({
schema: "freecad-web-carrier-partdesign-index/v1",
generatedAt: new Date().toISOString(),
documents: previous.documents,
}, null, 2)}\n`);
const built = results.length;
console.log(`\n${built}/${queue.length} 件完成${failed ? `,${failed} 件失败` : ""};索引 ${path.relative(caseDir, indexFile)}`);
if (flags.has("--dry")) console.log(JSON.stringify(results.map(item => ({ id: item.id, volume: item.volume, steps: item.steps }))));
process.exit(failed ? 1 : 0);
}
main().catch(error => {
console.error(error?.stack ?? error);
process.exit(1);
});
void fileURLToPath;

View File

@@ -0,0 +1,132 @@
// One recorded PartDesign build session for a carrier part.
//
// Every builder call goes through `part.timed()`, which is what makes the build
// replayable: the trace carries the exact kernel action, its arguments and the
// document listing after the call (tools/fcweb/kernel.mjs:188). The replay
// generator then derives one volume/mesh record per step from those listings.
//
// Object names are chosen by the builder (HullSketch1, HullLoft …) so the
// feature tree reads like a drawing, not like Sketch001. The UI renames on
// rebuild; web/tools/cad-ui-rebuild/drive.mjs maps the recorded names onto the
// names the workspace actually created.
import path from "node:path";
import fs from "node:fs";
import { fileURLToPath } from "node:url";
import { openPartDesign } from "../../../../../tools/fcweb/partdesign.mjs";
import { configureOpfs, readExportFile } from "../../../../../tools/fcweb/opfs.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
export const caseDir = path.resolve(here, "..");
export const outDir = path.join(caseDir, "out");
/** Point the shared OPFS mirror at this case's out/, per the OPFS contract. */
export function useCaseOpfs() {
return configureOpfs({ root: path.join(outDir, "opfs", "freecad-exports") });
}
export class Build {
constructor(part, { document, builder }) {
this.part = part;
this.document = document;
this.builder = builder ?? null;
this.counters = new Map();
this.steps = [];
}
/** Next name with an increasing suffix: `name("Sketch")` -> Sketch3. */
name(prefix) {
const next = (this.counters.get(prefix) ?? 0) + 1;
this.counters.set(prefix, next);
return `${prefix}${next}`;
}
record(object, label, action, args) {
const result = this.part.timed(`${this.document} · ${label}`, action, { object, body: "Body", ...args });
this.steps.push({ object, label, action, args });
return result;
}
/** Rectangle / Circle / Wire / Geometry sketch. `args` are setSketch fields. */
sketch(object, { profileType = "Rectangle", parameters, position, placementRotation, points, geometries, constraints }, label) {
this.stepsByName ??= new Map();
const args = { profileType };
if (parameters) args.parameters = parameters;
if (position) args.position = position;
if (placementRotation) args.placementRotation = placementRotation;
if (points) args.points = points;
if (geometries) args.geometries = geometries;
if (constraints) args.constraints = constraints;
return this.record(object, label ?? `草图 ${object}`, "setSketch", args);
}
/** Pad / Pocket / Revolution / Groove / Hole / Loft / Pipe (+ subtractive twins). */
feature(object, { featureType = "Pad", profile, length, angle, axis, depth, depthType, midplane, reversed, sections, ruled, closed, spine, pipeMode, transition }, label) {
const args = { featureType, profile };
for (const [key, value] of Object.entries({ length, angle, axis, depth, depthType, midplane, reversed, sections, ruled, closed, spine, pipeMode, transition })) {
if (value !== undefined) args[key] = value;
}
return this.record(object, label ?? `${featureType} ${object}`, "setFeature", args);
}
transform(object, { transformType, originals, direction, mirrorPlane, rotationAxis, length, angle, occurrences, reversed }, label) {
const args = { transformType, originals };
for (const [key, value] of Object.entries({ direction, mirrorPlane, rotationAxis, length, angle, occurrences, reversed })) {
if (value !== undefined) args[key] = value;
}
return this.record(object, label ?? `${transformType} ${object}`, "setTransform", args);
}
dressUp(object, { dressUpType, base, size, edges, useAllEdges, chamferType, size2, angle, flipDirection }, label) {
const args = { dressUpType, base };
for (const [key, value] of Object.entries({ size, edges, useAllEdges, chamferType, size2, angle, flipDirection })) {
if (value !== undefined) args[key] = value;
}
return this.record(object, label ?? `${dressUpType} ${object}`, "setDressUp", args);
}
primitive(object, { primitiveType, parameters, position }, label) {
return this.record(object, label ?? `${primitiveType} ${object}`, "setPrimitive", { primitiveType, parameters, position });
}
}
/**
* Build one document end to end and persist the three artefacts that the rest
* of the toolkit consumes: FCStd (OPFS mirror + evidence copy), trace JSON and,
* indirectly through the trace, the replay.
*/
export async function buildDocument(module, options = {}) {
const { document, builder, build } = module;
const part = await openPartDesign(document, { builder });
const session = new Build(part, { document, builder });
const started = Date.now();
try {
await build(session);
configureOpfs({ root: path.join(outDir, "opfs", "freecad-exports") });
const saved = part.saveDocument();
const bytes = readExportFile(saved.name);
const fcstdDir = path.join(outDir, "FCStd");
fs.mkdirSync(fcstdDir, { recursive: true });
fs.writeFileSync(path.join(fcstdDir, saved.name), bytes);
const traceDir = path.join(outDir, "traces");
fs.mkdirSync(traceDir, { recursive: true });
const trace = part.trace();
fs.writeFileSync(path.join(traceDir, `${document}.json`), `${JSON.stringify(trace, null, 2)}\n`);
const objects = part.snapshot().objects ?? [];
const body = objects.find(object => object.type === "PartDesign::Body");
// The kernel snapshot exposes volume/faceCount/edgeCount per object but no
// bounding box, so replay checks compare those three numbers (plus the step
// list) rather than a bbox.
const summary = {
document, builder, steps: session.steps.length,
volume: body?.volume ?? null,
faceCount: body?.faceCount ?? null,
edgeCount: body?.edgeCount ?? null,
seconds: Number(((Date.now() - started) / 1000).toFixed(2)),
fcstd: path.relative(caseDir, path.join(fcstdDir, saved.name)),
};
if (options.dry) console.log(JSON.stringify(summary));
return summary;
} finally {
part.dispose?.();
}
}

View File

@@ -0,0 +1,132 @@
// Sketch geometry helpers for the carrier PartDesign parts.
//
// The kernel's `setSketch` accepts three authored profile types: Rectangle and
// Circle carry named dimensions, and `Geometry` carries an explicit
// geometry list plus a constraint list (PartDesignDocumentWorkflow.cpp:2302).
// Only the Geometry form can describe a hull section or a wing planform, and a
// Geometry wire is closed ONLY when consecutive edges are joined by Coincident
// constraints -- the kernel runs the solver and then hands the wire to
// Pad/Loft, which rejects an open profile. So every polygon built here ends
// with an explicit coincident chain, exactly like the built-in Rectangle does
// (PartDesignDocumentWorkflow.cpp:2295).
//
// Coordinates are 2D on the sketch plane; z stays 0 and the sketch's
// placementRotation puts it where it belongs (a hull station is a YZ plane, a
// deck plan is XY).
const r9 = value => Math.round(Number(value) * 1e9) / 1e9;
const pt = (x, y) => [r9(x), r9(y), 0];
/** One line segment geometry row. */
export function line(start, end) {
return { type: "line", start: pt(start[0], start[1]), end: pt(end[0], end[1]) };
}
/** One arc geometry row; angles in radians, as the kernel reports them. */
export function arc(center, radius, startAngle, endAngle) {
return {
type: "arc", center: pt(center[0], center[1]), radius: r9(radius),
startAngle: r9(startAngle), endAngle: r9(endAngle),
};
}
/** Circle geometry (used inside a Geometry profile, e.g. a hole cut). */
export function circle(center, radius) {
return { type: "circle", center: pt(center[0], center[1]), radius: r9(radius) };
}
/**
* Turn a closed point loop into `{ geometries, constraints }`.
*
* The loop is emitted as lines and closed with a coincident chain; a tiny
* optional `radius` corner rounding is NOT applied here because two arcs and
* two lines would need tangent constraints the solver has to satisfy, and a
* hull section built from many stations does not need it (the loft smooths).
*/
export function polygon(points) {
const geometries = [];
const constraints = [];
const n = points.length;
for (let i = 0; i < n; i += 1) {
geometries.push(line(points[i], points[(i + 1) % n]));
}
for (let i = 0; i < n; i += 1) {
constraints.push({
type: "Coincident",
first: i, firstPos: "end",
second: (i + 1) % n, secondPos: "start",
});
}
return { geometries, constraints };
}
/** Rectangle loop centred on the sketch origin. */
export function rectPoints(cx, cy, width, height) {
const hw = width / 2, hh = height / 2;
return [
[cx - hw, cy - hh], [cx + hw, cy - hh],
[cx + hw, cy + hh], [cx - hw, cy + hh],
];
}
/** Rectangle profile as a Geometry sketch body. */
export function rect(cx, cy, width, height) {
return polygon(rectPoints(cx, cy, width, height));
}
/**
* A band (long thin rectangle) whose axis runs at `angleDeg` from +X, centred
* on (cx, cy). Catapult tracks, arrestor wires and deck markings are bands.
*/
export function band(cx, cy, length, width, angleDeg = 0) {
const a = (angleDeg * Math.PI) / 180;
const ux = Math.cos(a), uy = Math.sin(a);
const vx = -uy, vy = ux;
const hl = length / 2, hw = width / 2;
const corner = (l, w) => [cx + ux * l + vx * w, cy + uy * l + vy * w];
return polygon([corner(-hl, -hw), corner(hl, -hw), corner(hl, hw), corner(-hl, hw)]);
}
/**
* Merge several closed loops into one multi-wire profile.
*
* Pad/Loft accept a profile made of several closed wires; a single sketch with
* four elevator openings is one feature instead of four, which is the lesson
* the reducer gear learned the hard way (chained recompute is the cost, not
* the geometry).
*/
export function merge(...shapes) {
const geometries = [];
const constraints = [];
let offset = 0;
for (const shape of shapes) {
geometries.push(...shape.geometries);
for (const constraint of shape.constraints) {
const shifted = { ...constraint };
if (typeof shifted.first === "number") shifted.first += offset;
if (typeof shifted.second === "number") shifted.second += offset;
constraints.push(shifted);
}
offset += shape.geometries.length;
}
return { geometries, constraints };
}
/** Quaternion for a sketch plane rotated `angleDeg` about `axis` ("x"|"y"|"z"). */
export function rotation(axis, angleDeg) {
const half = (angleDeg * Math.PI) / 360;
const s = Math.sin(half), c = Math.cos(half);
if (axis === "x") return [s, 0, 0, c];
if (axis === "y") return [0, s, 0, c];
return [0, 0, s, c];
}
/**
* Convenience: a sketch plane whose local XY is the world YZ plane at `x`.
* Rotation -90 about Y maps local +X onto world +Z, so a station point is
* written (height, beam) and reads the same way in the drawing.
*/
export const stationAt = x => ({ position: [x, 0, 0], placementRotation: rotation("y", -90) });
/** Convenience: a sketch plane whose local XY is the world XZ plane at `y`. */
export const sideAt = y => ({ position: [0, y, 0], placementRotation: rotation("x", 90) });

View File

@@ -0,0 +1,207 @@
{
"schema": "freecad-web-carrier-partdesign-index/v1",
"generatedAt": "2026-11-25T09:39:12.743Z",
"documents": {
"CarrierCiws": {
"id": "P10",
"title": "近防炮",
"system": "weapons",
"steps": 8,
"volume": 55.99481508149678,
"bounds": null,
"seconds": 1.92,
"fcstd": "out/FCStd/CarrierCiws.FCStd",
"builtAt": "2026-11-25T02:42:05.877Z"
},
"CarrierDeck": {
"id": "P02",
"title": "飞行甲板",
"system": "flight-deck",
"steps": 14,
"volume": 35733.026212188044,
"seconds": 26.5,
"fcstd": "out/FCStd/CarrierDeck.FCStd",
"builtAt": "2026-11-25T03:21:46.285Z"
},
"CarrierAngledDeck": {
"id": "P03",
"title": "斜角甲板",
"system": "angled-deck",
"steps": 2,
"volume": 6912.000000095107,
"seconds": 0.57,
"fcstd": "out/FCStd/CarrierAngledDeck.FCStd",
"builtAt": "2026-11-25T02:45:28.101Z"
},
"CarrierHangar": {
"id": "P05",
"title": "机库",
"system": "hangar",
"steps": 4,
"volume": 39639.999999999985,
"seconds": 1.75,
"fcstd": "out/FCStd/CarrierHangar.FCStd",
"builtAt": "2026-11-25T09:39:12.743Z"
},
"CarrierElevators": {
"id": "P06",
"title": "升降机",
"system": "aircraft-handling",
"steps": 8,
"volume": 1007.9999999999995,
"seconds": 1.7,
"fcstd": "out/FCStd/CarrierElevators.FCStd",
"builtAt": "2026-11-25T02:45:46.125Z"
},
"CarrierCatapults": {
"id": "P07",
"title": "弹射器",
"system": "aircraft-handling",
"steps": 8,
"volume": 346.5000000205559,
"seconds": 17.61,
"fcstd": "out/FCStd/CarrierCatapults.FCStd",
"builtAt": "2026-11-25T02:46:22.809Z"
},
"CarrierArrestorWires": {
"id": "P08",
"title": "拦阻索",
"system": "aircraft-handling",
"steps": 8,
"volume": 25.199999999999346,
"seconds": 1.91,
"fcstd": "out/FCStd/CarrierArrestorWires.FCStd",
"builtAt": "2026-11-25T02:46:34.582Z"
},
"CarrierRadar": {
"id": "P09",
"title": "相控阵雷达",
"system": "sensors",
"steps": 6,
"volume": 69.33026138282548,
"seconds": 1.2,
"fcstd": "out/FCStd/CarrierRadar.FCStd",
"builtAt": "2026-11-25T02:46:37.834Z"
},
"CarrierMarkings": {
"id": "P20",
"title": "甲板标线",
"system": "markings",
"steps": 6,
"volume": 25.959599999996996,
"seconds": 4.16,
"fcstd": "out/FCStd/CarrierMarkings.FCStd",
"builtAt": "2026-11-25T02:46:42.963Z"
},
"CarrierHull": {
"id": "P01",
"title": "舰体",
"system": "hull-structure",
"steps": 10,
"volume": 260846.77920152084,
"seconds": 4.04,
"fcstd": "out/FCStd/CarrierHull.FCStd",
"builtAt": "2026-11-25T02:59:31.032Z"
},
"CarrierIsland": {
"id": "P04",
"title": "舰岛",
"system": "island",
"steps": 11,
"volume": 10658.25,
"seconds": 10.23,
"fcstd": "out/FCStd/CarrierIsland.FCStd",
"builtAt": "2026-11-25T02:59:42.332Z"
},
"CarrierFighterA": {
"id": "P11",
"title": "舰载战斗机 A",
"system": "air-fighter",
"steps": 13,
"volume": 82.94751637748307,
"seconds": 12.63,
"fcstd": "out/FCStd/CarrierFighterA.FCStd",
"builtAt": "2026-11-25T03:06:11.062Z"
},
"CarrierFighterB": {
"id": "P12",
"title": "舰载战斗机 B",
"system": "air-fighter",
"steps": 13,
"volume": 87.54004703082904,
"seconds": 13.06,
"fcstd": "out/FCStd/CarrierFighterB.FCStd",
"builtAt": "2026-11-25T03:07:17.468Z"
},
"CarrierFighterC": {
"id": "P13",
"title": "舰载战斗机 C",
"system": "air-fighter",
"steps": 13,
"volume": 74.27704220951199,
"seconds": 13.68,
"fcstd": "out/FCStd/CarrierFighterC.FCStd",
"builtAt": "2026-11-25T03:07:32.109Z"
},
"CarrierFighterD": {
"id": "P14",
"title": "舰载战斗机 D",
"system": "air-fighter",
"steps": 13,
"volume": 92.30909038541577,
"seconds": 13.55,
"fcstd": "out/FCStd/CarrierFighterD.FCStd",
"builtAt": "2026-11-25T03:07:46.614Z"
},
"CarrierFighterE": {
"id": "P15",
"title": "舰载战斗机 E",
"system": "air-fighter",
"steps": 13,
"volume": 78.52773673764473,
"seconds": 14.64,
"fcstd": "out/FCStd/CarrierFighterE.FCStd",
"builtAt": "2026-11-25T03:08:02.233Z"
},
"CarrierFighterF": {
"id": "P16",
"title": "舰载战斗机 F",
"system": "air-fighter",
"steps": 13,
"volume": 85.22195279514976,
"seconds": 12.63,
"fcstd": "out/FCStd/CarrierFighterF.FCStd",
"builtAt": "2026-11-25T03:08:15.840Z"
},
"CarrierAwacs": {
"id": "P17",
"title": "舰载预警机",
"system": "air-awacs",
"steps": 21,
"volume": 254.94042344150378,
"seconds": 34.17,
"fcstd": "out/FCStd/CarrierAwacs.FCStd",
"builtAt": "2026-11-25T03:08:50.977Z"
},
"CarrierHelicopterA": {
"id": "P18",
"title": "舰载直升机 A",
"system": "air-rotor",
"steps": 13,
"volume": 48.34826428466978,
"seconds": 8.63,
"fcstd": "out/FCStd/CarrierHelicopterA.FCStd",
"builtAt": "2026-11-25T03:09:00.538Z"
},
"CarrierHelicopterB": {
"id": "P19",
"title": "舰载直升机 B",
"system": "air-rotor",
"steps": 13,
"volume": 48.39866428466979,
"seconds": 8.87,
"fcstd": "out/FCStd/CarrierHelicopterB.FCStd",
"builtAt": "2026-11-25T03:09:10.413Z"
}
}
}

View File

@@ -0,0 +1 @@
{"schema":"freecad-web-process-replay/v1","document":"CarrierAngledDeck","source":"web/teaching/cases/carrier-partdesign/out/FCStd/CarrierAngledDeck.FCStd","meshMs":69,"steps":[{"step":1,"label":"CarrierAngledDeck · 斜角甲板平面","action":"setSketch","seconds":0.0598,"args":{"object":"AngledPlan","body":"Body","profileType":"Geometry","position":[0,0,24],"geometries":{"count":4,"sha256":"4db5d5b809389276"},"constraints":{"count":4,"sha256":"a7dc762a36ba48a3"}},"feature":"AngledPlan","volume":0,"faceCount":1,"mesh":{"positions":[77.162,4.584,24,-157.162,-52.584,24,80.502,-19.182,24,77.162,4.584,24,-160.502,-28.818,24,-157.162,-52.584,24],"normals":[0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":2,"bounds":[-160.50224546100003,-52.58398894,24,80.502245461,4.583988940000001,24]}},{"step":2,"label":"CarrierAngledDeck · 斜角甲板","action":"setFeature","seconds":0.2388,"args":{"object":"AngledPad","body":"Body","featureType":"Pad","profile":"AngledPlan","length":1.2},"feature":"AngledPad","volume":6912.000000095107,"faceCount":6,"mesh":{"positions":[-157.162,-52.584,24,80.502,-19.182,24,-157.162,-52.584,25.2,-157.162,-52.584,25.2,80.502,-19.182,24,80.502,-19.182,25.2,80.502,-19.182,24,77.162,4.584,24,80.502,-19.182,25.2,80.502,-19.182,25.2,77.162,4.584,24,77.162,4.584,25.2,77.162,4.584,24,-160.502,-28.818,24,77.162,4.584,25.2,77.162,4.584,25.2,-160.502,-28.818,24,-160.502,-28.818,25.2,-160.502,-28.818,24,-157.162,-52.584,24,-160.502,-28.818,25.2,-160.502,-28.818,25.2,-157.162,-52.584,24,-157.162,-52.584,25.2,-157.162,-52.584,24,77.162,4.584,24,80.502,-19.182,24,-160.502,-28.818,24,77.162,4.584,24,-157.162,-52.584,24,77.162,4.584,25.2,-157.162,-52.584,25.2,80.502,-19.182,25.2,77.162,4.584,25.2,-160.502,-28.818,25.2,-157.162,-52.584,25.2],"normals":[0.139,-0.99,0,0.139,-0.99,0,0.139,-0.99,0,0.139,-0.99,0,0.139,-0.99,0,0.139,-0.99,0,0.99,0.139,0,0.99,0.139,0,0.99,0.139,0,0.99,0.139,0,0.99,0.139,0,0.99,0.139,0,-0.139,0.99,0,-0.139,0.99,0,-0.139,0.99,0,-0.139,0.99,0,-0.139,0.99,0,-0.139,0.99,0,-0.99,-0.139,0,-0.99,-0.139,0,-0.99,-0.139,0,-0.99,-0.139,0,-0.99,-0.139,0,-0.99,-0.139,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":12,"bounds":[-160.50224546100003,-52.58398894,24,80.502245461,4.583988940000001,25.2]}}]}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{"schema":"freecad-web-process-replay/v1","document":"CarrierHangar","source":"web/teaching/cases/carrier-partdesign/out/FCStd/CarrierHangar.FCStd","meshMs":130,"steps":[{"step":1,"label":"CarrierHangar · 机库外壳平面","action":"setSketch","seconds":0.1795,"args":{"object":"HangarShellSketch","body":"Body","profileType":"Geometry","position":[0,0,8],"geometries":{"count":4,"sha256":"33b2eb432edc596c"},"constraints":{"count":4,"sha256":"a7dc762a36ba48a3"}},"feature":"HangarShellSketch","volume":0,"faceCount":1,"mesh":{"positions":[60,17,8,-140,-17,8,60,-17,8,60,17,8,-140,17,8,-140,-17,8],"normals":[0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":2,"bounds":[-140,-17,8,60,17,8]}},{"step":2,"label":"CarrierHangar · 机库外壳","action":"setFeature","seconds":0.2389,"args":{"object":"HangarShell","body":"Body","featureType":"Pad","profile":"HangarShellSketch","length":16},"feature":"HangarShell","volume":108800.00000000003,"faceCount":6,"mesh":{"positions":[-140,-17,8,60,-17,8,-140,-17,24,-140,-17,24,60,-17,8,60,-17,24,60,-17,8,60,17,24,60,-17,24,60,-17,8,60,17,8,60,17,24,60,17,8,-140,17,8,60,17,24,60,17,24,-140,17,8,-140,17,24,-140,17,8,-140,-17,24,-140,17,24,-140,17,8,-140,-17,8,-140,-17,24,-140,-17,8,60,17,8,60,-17,8,-140,17,8,60,17,8,-140,-17,8,60,17,24,-140,-17,24,60,-17,24,60,17,24,-140,17,24,-140,-17,24],"normals":[0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":12,"bounds":[-140,-17,8,60,17,24]}},{"step":3,"label":"CarrierHangar · 机库内腔平面","action":"setSketch","seconds":0.0737,"args":{"object":"HangarCavitySketch","body":"Body","profileType":"Geometry","position":[0,0,24],"geometries":{"count":4,"sha256":"e7903266b587a746"},"constraints":{"count":4,"sha256":"a7dc762a36ba48a3"}},"feature":"HangarCavitySketch","volume":0,"faceCount":1,"mesh":{"positions":[55,14,24,-135,-14,24,55,-14,24,55,14,24,-135,14,24,-135,-14,24],"normals":[0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":2,"bounds":[-135,-14,24,55,14,24]}},{"step":4,"label":"CarrierHangar · 掏空内腔","action":"setFeature","seconds":0.3998,"args":{"object":"HangarCavity","body":"Body","featureType":"Pocket","profile":"HangarCavitySketch","length":13},"feature":"HangarCavity","volume":39639.999999999985,"faceCount":11,"mesh":{"positions":[-140,-17,8,60,-17,8,-140,-17,24,-140,-17,24,60,-17,8,60,-17,24,-140,17,8,-140,-17,24,-140,17,24,-140,17,8,-140,-17,8,-140,-17,24,60,-17,8,60,17,24,60,-17,24,60,-17,8,60,17,8,60,17,24,-140,-17,8,60,17,8,60,-17,8,-140,17,8,60,17,8,-140,-17,8,-135,14,24,-140,17,24,-140,-17,24,-135,14,24,-140,-17,24,-135,-14,24,60,-17,24,55,-14,24,-135,-14,24,60,-17,24,-135,-14,24,-140,-17,24,60,17,24,55,14,24,55,-14,24,60,17,24,55,-14,24,60,-17,24,60,17,24,-140,17,24,-135,14,24,60,17,24,-135,14,24,55,14,24,60,17,8,-140,17,8,60,17,24,60,17,24,-140,17,8,-140,17,24,-135,-14,24,55,-14,24,-135,-14,11,-135,-14,11,55,-14,24,55,-14,11,55,-14,24,55,14,11,55,-14,11,55,-14,24,55,14,24,55,14,11,55,14,24,-135,14,24,55,14,11,55,14,11,-135,14,24,-135,14,11,-135,14,24,-135,-14,11,-135,14,11,-135,14,24,-135,-14,24,-135,-14,11,55,14,11,-135,-14,11,55,-14,11,55,14,11,-135,14,11,-135,-14,11],"normals":[0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1],"triangleCount":28,"bounds":[-140,-17,8,60,17,24]}}]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
{
"schema": "freecad-web-process-replay/v1",
"generatedAt": "2026-11-25T09:42:37.240Z",
"documents": [
{
"document": "CarrierHangar",
"kind": "part",
"events": 4,
"steps": 4,
"withMesh": 4,
"solids": 4,
"bytes": 3893,
"meshMs": 130
}
],
"failures": []
}

View File

@@ -0,0 +1,286 @@
{
"schema": "freecad-web-process-trace/v1",
"document": "CarrierAngledDeck",
"builder": "deck",
"totals": {
"seconds": 0.299,
"steps": 2,
"timings": [
{
"label": "CarrierAngledDeck · 斜角甲板平面",
"action": "setSketch",
"seconds": 0.059793516000000636
},
{
"label": "CarrierAngledDeck · 斜角甲板",
"action": "setFeature",
"seconds": 0.238780385
}
]
},
"events": [
{
"step": 1,
"label": "CarrierAngledDeck · 斜角甲板平面",
"action": "setSketch",
"args": {
"object": "AngledPlan",
"body": "Body",
"profileType": "Geometry",
"position": [
0,
0,
24
],
"geometries": {
"count": 4,
"sha256": "4db5d5b809389276"
},
"constraints": {
"count": 4,
"sha256": "a7dc762a36ba48a3"
}
},
"seconds": 0.0598,
"tips": {
"objectCount": 10,
"tip": "AngledPlan",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": null,
"faceCount": 0,
"edgeCount": null,
"vertexCount": 0
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "AngledPlan",
"label": "AngledPlan",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
24
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
}
]
}
},
{
"step": 2,
"label": "CarrierAngledDeck · 斜角甲板",
"action": "setFeature",
"args": {
"object": "AngledPad",
"body": "Body",
"featureType": "Pad",
"profile": "AngledPlan",
"length": 1.2
},
"seconds": 0.2388,
"tips": {
"objectCount": 11,
"tip": "AngledPad",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 6912.000000095107,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "AngledPlan",
"label": "AngledPlan",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
24
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "AngledPad",
"label": "AngledPad",
"type": "PartDesign::Pad",
"position": [
0,
0,
24
],
"volume": 6912.000000095107,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
}
]
}
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,615 @@
{
"schema": "freecad-web-process-trace/v1",
"document": "CarrierHangar",
"builder": "hangar",
"totals": {
"seconds": 0.892,
"steps": 4,
"timings": [
{
"label": "CarrierHangar · 机库外壳平面",
"action": "setSketch",
"seconds": 0.179451726
},
{
"label": "CarrierHangar · 机库外壳",
"action": "setFeature",
"seconds": 0.23893987600000013
},
{
"label": "CarrierHangar · 机库内腔平面",
"action": "setSketch",
"seconds": 0.07365641499999992
},
{
"label": "CarrierHangar · 掏空内腔",
"action": "setFeature",
"seconds": 0.3998322840000001
}
]
},
"events": [
{
"step": 1,
"label": "CarrierHangar · 机库外壳平面",
"action": "setSketch",
"args": {
"object": "HangarShellSketch",
"body": "Body",
"profileType": "Geometry",
"position": [
0,
0,
8
],
"geometries": {
"count": 4,
"sha256": "33b2eb432edc596c"
},
"constraints": {
"count": 4,
"sha256": "a7dc762a36ba48a3"
}
},
"seconds": 0.1795,
"tips": {
"objectCount": 10,
"tip": "HangarShellSketch",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": null,
"faceCount": 0,
"edgeCount": null,
"vertexCount": 0
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "HangarShellSketch",
"label": "HangarShellSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
8
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
}
]
}
},
{
"step": 2,
"label": "CarrierHangar · 机库外壳",
"action": "setFeature",
"args": {
"object": "HangarShell",
"body": "Body",
"featureType": "Pad",
"profile": "HangarShellSketch",
"length": 16
},
"seconds": 0.2389,
"tips": {
"objectCount": 11,
"tip": "HangarShell",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 108800.00000000003,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "HangarShellSketch",
"label": "HangarShellSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
8
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "HangarShell",
"label": "HangarShell",
"type": "PartDesign::Pad",
"position": [
0,
0,
8
],
"volume": 108800.00000000003,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
}
]
}
},
{
"step": 3,
"label": "CarrierHangar · 机库内腔平面",
"action": "setSketch",
"args": {
"object": "HangarCavitySketch",
"body": "Body",
"profileType": "Geometry",
"position": [
0,
0,
24
],
"geometries": {
"count": 4,
"sha256": "e7903266b587a746"
},
"constraints": {
"count": 4,
"sha256": "a7dc762a36ba48a3"
}
},
"seconds": 0.0737,
"tips": {
"objectCount": 12,
"tip": "HangarCavitySketch",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 108800.00000000003,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "HangarShellSketch",
"label": "HangarShellSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
8
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "HangarShell",
"label": "HangarShell",
"type": "PartDesign::Pad",
"position": [
0,
0,
8
],
"volume": 108800.00000000003,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
},
{
"name": "HangarCavitySketch",
"label": "HangarCavitySketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
24
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
}
]
}
},
{
"step": 4,
"label": "CarrierHangar · 掏空内腔",
"action": "setFeature",
"args": {
"object": "HangarCavity",
"body": "Body",
"featureType": "Pocket",
"profile": "HangarCavitySketch",
"length": 13
},
"seconds": 0.3998,
"tips": {
"objectCount": 13,
"tip": "HangarCavity",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 39639.999999999985,
"faceCount": 11,
"edgeCount": 24,
"vertexCount": 16
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "HangarShellSketch",
"label": "HangarShellSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
8
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "HangarShell",
"label": "HangarShell",
"type": "PartDesign::Pad",
"position": [
0,
0,
8
],
"volume": 108800.00000000003,
"faceCount": 6,
"edgeCount": 12,
"vertexCount": 8
},
{
"name": "HangarCavitySketch",
"label": "HangarCavitySketch",
"type": "Sketcher::SketchObject",
"position": [
0,
0,
24
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "HangarCavity",
"label": "HangarCavity",
"type": "PartDesign::Pocket",
"position": [
0,
0,
8
],
"volume": 39639.999999999985,
"faceCount": 11,
"edgeCount": 24,
"vertexCount": 16
}
]
}
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,996 @@
{
"schema": "freecad-web-process-trace/v1",
"document": "CarrierRadar",
"builder": "sensors",
"totals": {
"seconds": 1.064,
"steps": 6,
"timings": [
{
"label": "CarrierRadar · 雷达基座截面",
"action": "setSketch",
"seconds": 0.030709644000002298
},
{
"label": "CarrierRadar · 雷达基座",
"action": "setFeature",
"seconds": 0.06350509900000179
},
{
"label": "CarrierRadar · 阵面草图",
"action": "setSketch",
"seconds": 0.05788390299999446
},
{
"label": "CarrierRadar · 相控阵面",
"action": "setFeature",
"seconds": 0.4745789090000035
},
{
"label": "CarrierRadar · 阵面支架截面",
"action": "setSketch",
"seconds": 0.08302601299999515
},
{
"label": "CarrierRadar · 阵面支架",
"action": "setFeature",
"seconds": 0.35445988500000386
}
]
},
"events": [
{
"step": 1,
"label": "CarrierRadar · 雷达基座截面",
"action": "setSketch",
"args": {
"object": "RadarPedestalSketch",
"body": "Body",
"profileType": "Circle",
"parameters": {
"Radius": 2.2
},
"position": [
4,
28,
53
]
},
"seconds": 0.0307,
"tips": {
"objectCount": 10,
"tip": "RadarPedestalSketch",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": null,
"faceCount": 0,
"edgeCount": null,
"vertexCount": 0
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
}
]
}
},
{
"step": 2,
"label": "CarrierRadar · 雷达基座",
"action": "setFeature",
"args": {
"object": "RadarPedestal",
"body": "Body",
"featureType": "Pad",
"profile": "RadarPedestalSketch",
"length": 3
},
"seconds": 0.0635,
"tips": {
"objectCount": 11,
"tip": "RadarPedestal",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 45.6159253301238,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarPedestal",
"label": "RadarPedestal",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 45.61592533012381,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
}
]
}
},
{
"step": 3,
"label": "CarrierRadar · 阵面草图",
"action": "setSketch",
"args": {
"object": "RadarFaceSketch",
"body": "Body",
"profileType": "Geometry",
"position": [
0,
28,
0
],
"placementRotation": [
0.7071067811865476,
0,
0,
0.7071067811865476
],
"geometries": {
"count": 4,
"sha256": "67346469493e7308"
},
"constraints": {
"count": 4,
"sha256": "a7dc762a36ba48a3"
}
},
"seconds": 0.0579,
"tips": {
"objectCount": 12,
"tip": "RadarFaceSketch",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 45.6159253301238,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarPedestal",
"label": "RadarPedestal",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 45.61592533012381,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "RadarFaceSketch",
"label": "RadarFaceSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
28,
0
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
}
]
}
},
{
"step": 4,
"label": "CarrierRadar · 相控阵面",
"action": "setFeature",
"args": {
"object": "RadarFace",
"body": "Body",
"featureType": "Pad",
"profile": "RadarFaceSketch",
"length": 0.6
},
"seconds": 0.4746,
"tips": {
"objectCount": 13,
"tip": "RadarFace",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 66.61592533012391,
"faceCount": 11,
"edgeCount": 22,
"vertexCount": 13
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarPedestal",
"label": "RadarPedestal",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 45.61592533012381,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "RadarFaceSketch",
"label": "RadarFaceSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
28,
0
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "RadarFace",
"label": "RadarFace",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 66.61592533012393,
"faceCount": 11,
"edgeCount": 22,
"vertexCount": 13
}
]
}
},
{
"step": 5,
"label": "CarrierRadar · 阵面支架截面",
"action": "setSketch",
"args": {
"object": "RadarFrameSketch",
"body": "Body",
"profileType": "Circle",
"parameters": {
"Radius": 0.6
},
"position": [
4,
28.9,
56
]
},
"seconds": 0.083,
"tips": {
"objectCount": 14,
"tip": "RadarFrameSketch",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 66.61592533012391,
"faceCount": 11,
"edgeCount": 22,
"vertexCount": 13
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarPedestal",
"label": "RadarPedestal",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 45.61592533012381,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "RadarFaceSketch",
"label": "RadarFaceSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
28,
0
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "RadarFace",
"label": "RadarFace",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 66.61592533012393,
"faceCount": 11,
"edgeCount": 22,
"vertexCount": 13
},
{
"name": "RadarFrameSketch",
"label": "RadarFrameSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28.9,
56
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
}
]
}
},
{
"step": 6,
"label": "CarrierRadar · 阵面支架",
"action": "setFeature",
"args": {
"object": "RadarFrame",
"body": "Body",
"featureType": "Pad",
"profile": "RadarFrameSketch",
"length": 2.4
},
"seconds": 0.3545,
"tips": {
"objectCount": 15,
"tip": "RadarFrame",
"objects": [
{
"name": "Body",
"label": "Body",
"type": "PartDesign::Body",
"position": [
0,
0,
0
],
"volume": 69.33026138282548,
"faceCount": 13,
"edgeCount": 25,
"vertexCount": 15
},
{
"name": "Origin",
"label": "Origin",
"type": "App::Origin",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "X_Axis",
"label": "X-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Y_Axis",
"label": "Y-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Z_Axis",
"label": "Z-axis",
"type": "App::Line",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XY_Plane",
"label": "XY-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "XZ_Plane",
"label": "XZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "YZ_Plane",
"label": "YZ-plane",
"type": "App::Plane",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "Origin001",
"label": "Origin001",
"type": "App::Point",
"volume": null,
"faceCount": null,
"edgeCount": null,
"vertexCount": null
},
{
"name": "RadarPedestalSketch",
"label": "RadarPedestalSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28,
53
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarPedestal",
"label": "RadarPedestal",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 45.61592533012381,
"faceCount": 3,
"edgeCount": 3,
"vertexCount": 2
},
{
"name": "RadarFaceSketch",
"label": "RadarFaceSketch",
"type": "Sketcher::SketchObject",
"position": [
0,
28,
0
],
"volume": 0,
"faceCount": 0,
"edgeCount": 4,
"vertexCount": 4
},
{
"name": "RadarFace",
"label": "RadarFace",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 66.61592533012393,
"faceCount": 11,
"edgeCount": 22,
"vertexCount": 13
},
{
"name": "RadarFrameSketch",
"label": "RadarFrameSketch",
"type": "Sketcher::SketchObject",
"position": [
4,
28.9,
56
],
"volume": 0,
"faceCount": 0,
"edgeCount": 1,
"vertexCount": 1
},
{
"name": "RadarFrame",
"label": "RadarFrame",
"type": "PartDesign::Pad",
"position": [
4,
28,
53
],
"volume": 69.3302613828255,
"faceCount": 13,
"edgeCount": 25,
"vertexCount": 15
}
]
}
}
]
}

View File

@@ -0,0 +1,230 @@
// 舰载机(P11–P19):战斗机、预警机、直升机。
//
// Every airframe is built in its own local frame -- nose along +X, the fuselage
// centreline on the X axis, wings on the XY plane -- so a Revolution about the
// body origin's X axis is the fuselage and a Mirrored about XZ makes the
// second wing. The assembly then places each airframe on the deck with a
// position and a heading.
//
// This is the part family where PartDesign earns its place: the fuselage is a
// lathed profile, the wing is a swept planform Pad, the stabiliser is its
// mirrored twin, and the canopy is a primitive dome. Six fighters share one
// parameterised builder; the AWACS adds a rotodome and four nacelles; the two
// helicopters add a PolarPattern rotor.
import { polygon, band, stationAt, sideAt, rotation } from "../lib/sketch.mjs";
const X_AXIS = "X_Axis";
const XZ_PLANE = { object: "XZ_Plane", subelements: [""] };
const Z_AXIS = { object: "Z_Axis", subelements: [""] };
/** Fighter fuselage half-profile, scaled to `length`. */
function fighterProfile(length) {
const s = length / 9.2;
return [
[9.2 * s, 0], [8.7 * s, 0.4 * s], [7.4 * s, 0.75 * s], [5 * s, 1.1 * s],
[2.5 * s, 1.25 * s], [0, 1.25 * s], [-2.8 * s, 1.15 * s], [-5.6 * s, 0.95 * s],
[-8 * s, 0.8 * s], [-9.2 * s, 0.6 * s], [-9.2 * s, 0],
];
}
function fighterWing(span) {
return [[2.6, 1.0], [-3.2, 1.0], [-4.4, span], [-1.2, span]];
}
function buildFighter(part, { length, span }) {
const s = length / 9.2;
// 1. Fuselage: half-profile revolved about the body X axis.
part.sketch("FuseSketch", {
profileType: "Geometry",
...polygon(fighterProfile(length)),
...sideAt(0),
}, "机身半剖");
part.feature("Fuselage", {
featureType: "Revolution", profile: "FuseSketch", axis: X_AXIS, angle: 360,
}, "机身回转");
// 2. Wing: swept planform, then its mirror image.
part.sketch("WingSketch", {
profileType: "Geometry",
...polygon(fighterWing(span)),
position: [0, 0, 0],
}, "右机翼平面");
part.feature("WingPad", {
featureType: "Pad", profile: "WingSketch", length: 0.32, midplane: true,
}, "右机翼");
part.transform("WingMirror", {
transformType: "Mirrored", originals: ["WingPad"], mirrorPlane: XZ_PLANE,
}, "左机翼镜像");
// 3. Horizontal stabiliser, mirrored the same way.
part.sketch("StabSketch", {
profileType: "Geometry",
...polygon([[-7.0 * s, 0.45], [-9.2 * s, 0.45], [-9.4 * s, 3.0], [-8.2 * s, 3.0]]),
position: [0, 0, 0],
}, "平尾平面");
part.feature("StabilizerPad", {
featureType: "Pad", profile: "StabSketch", length: 0.22, midplane: true,
}, "平尾");
part.transform("StabilizerMirror", {
transformType: "Mirrored", originals: ["StabilizerPad"], mirrorPlane: XZ_PLANE,
}, "平尾镜像");
// 4. Vertical tail in the XZ plane.
part.sketch("TailSketch", {
profileType: "Geometry",
...polygon([[-5.0 * s, 0.45], [-8.6 * s, 0.45], [-9.0 * s, 4.2], [-7.4 * s, 4.2]]),
...sideAt(0),
}, "垂尾平面");
part.feature("TailPad", {
featureType: "Pad", profile: "TailSketch", length: 0.2, midplane: true,
}, "垂尾");
// 5. Canopy dome and exhaust nozzle.
part.primitive("Canopy", {
primitiveType: "AdditiveSphere", parameters: { Radius: 0.8 }, position: [3.2 * s, 0, 1.15 * s],
}, "座舱盖");
part.sketch("NozzleSketch", {
profileType: "Circle", parameters: { Radius: 0.68 },
...stationAt(-9.3 * s),
}, "尾喷口截面");
part.feature("NozzlePad", {
featureType: "Pad", profile: "NozzleSketch", length: 1.4,
}, "尾喷口");
}
const FIGHTERS = [
{ id: "P11", document: "CarrierFighterA", length: 9.2, span: 6.6 },
{ id: "P12", document: "CarrierFighterB", length: 9.4, span: 6.8 },
{ id: "P13", document: "CarrierFighterC", length: 8.8, span: 6.2 },
{ id: "P14", document: "CarrierFighterD", length: 9.6, span: 7.0 },
{ id: "P15", document: "CarrierFighterE", length: 9.0, span: 6.4 },
{ id: "P16", document: "CarrierFighterF", length: 9.3, span: 6.7 },
];
export const fighters = FIGHTERS.map(cfg => ({
document: cfg.document,
builder: "aircraft",
build(part) { buildFighter(part, cfg); },
}));
// ---- 预警机 ----------------------------------------------------------------
export const awacs = {
document: "CarrierAwacs",
builder: "aircraft",
build(part) {
// 17 m fuselage, high aspect-ratio wing, four nacelles, rotodome.
part.sketch("FuseSketch", {
profileType: "Geometry",
...polygon([
[8.6, 0], [8.0, 0.5], [6.4, 1.0], [4.2, 1.5], [1.6, 1.7],
[-1.6, 1.7], [-4.6, 1.5], [-7.0, 1.2], [-8.2, 0.9], [-8.6, 0.4], [-8.6, 0],
]),
...sideAt(0),
}, "机身半剖");
part.feature("Fuselage", { featureType: "Revolution", profile: "FuseSketch", axis: X_AXIS, angle: 360 }, "机身回转");
part.sketch("WingSketch", {
profileType: "Geometry",
...polygon([[2.4, 0.8], [-1.8, 0.8], [-2.2, 11.6], [0.6, 11.6]]),
position: [0, 0, 1.4],
}, "右机翼平面");
part.feature("WingPad", { featureType: "Pad", profile: "WingSketch", length: 0.34, midplane: true }, "右机翼");
part.transform("WingMirror", { transformType: "Mirrored", originals: ["WingPad"], mirrorPlane: XZ_PLANE }, "左机翼镜像");
// Two nacelles per wing at y=4.2 and 8.6: two Pads, one mirror.
for (const y of [4.2, 8.6]) {
const sketch = part.name("NacelleSketch");
part.sketch(sketch, {
profileType: "Circle", parameters: { Radius: 0.55 },
...stationAt(-0.6), position: [-0.6, y, 1.4],
}, `桨舱截面 y=${y}`);
part.feature(part.name("NacellePad"), { featureType: "Pad", profile: sketch, length: 2.6 }, "桨舱");
}
part.transform("NacelleMirror", {
transformType: "Mirrored", originals: ["NacellePad1", "NacellePad2"], mirrorPlane: XZ_PLANE,
}, "桨舱镜像");
part.sketch("StabSketch", {
profileType: "Geometry",
...polygon([[-6.2, 0.5], [-8.4, 0.5], [-8.6, 4.2], [-7.4, 4.2]]),
position: [0, 0, 0.4],
}, "平尾平面");
part.feature("StabilizerPad", { featureType: "Pad", profile: "StabSketch", length: 0.24, midplane: true }, "平尾");
part.transform("StabilizerMirror", { transformType: "Mirrored", originals: ["StabilizerPad"], mirrorPlane: XZ_PLANE }, "平尾镜像");
part.sketch("TailSketch", {
profileType: "Geometry",
...polygon([[-5.8, 0.5], [-8.4, 0.5], [-8.6, 3.8], [-7.2, 3.8]]),
...sideAt(0),
}, "垂尾平面");
part.feature("TailPad", { featureType: "Pad", profile: "TailSketch", length: 0.22, midplane: true }, "垂尾");
// Rotodome on two struts.
for (const x of [-2.4, 2.4]) {
const sketch = part.name("StrutSketch");
part.sketch(sketch, {
profileType: "Circle", parameters: { Radius: 0.16 },
position: [x, 0, 1.2],
}, `旋罩支柱截面 x=${x}`);
part.feature(part.name("StrutPad"), { featureType: "Pad", profile: sketch, length: 3.8 }, "旋罩支柱");
}
part.sketch("RotodomeSketch", {
profileType: "Circle", parameters: { Radius: 5.8 }, position: [0, 0, 5.0],
}, "旋罩截面");
part.feature("RotodomePad", { featureType: "Pad", profile: "RotodomeSketch", length: 1.05 }, "雷达旋罩");
},
};
// ---- 直升机 ----------------------------------------------------------------
function buildHelicopter(part, { rotorSpan }) {
part.sketch("FuseSketch", {
profileType: "Geometry",
...polygon([
[3.6, 0], [3.3, 0.5], [2.4, 1.2], [0.8, 1.65], [-1.2, 1.7],
[-2.6, 1.4], [-3.4, 0.9], [-3.6, 0.2], [-3.6, 0],
]),
...sideAt(0),
}, "机身半剖");
part.feature("Fuselage", { featureType: "Revolution", profile: "FuseSketch", axis: X_AXIS, angle: 360 }, "机身回转");
// Tail boom, tail fin, tail rotor.
// Boom: drawn at the aft end and padded forward into the fuselage so the
// body stays one solid (Pad extrudes along +X from its sketch plane).
part.sketch("BoomSketch", {
profileType: "Circle", parameters: { Radius: 0.33 }, ...stationAt(-11.0),
}, "尾梁截面");
part.feature("TailBoom", { featureType: "Pad", profile: "BoomSketch", length: 7.6 }, "尾梁");
part.sketch("FinSketch", {
profileType: "Geometry", ...polygon([[-9.6, 0.1], [-11.0, 0.1], [-11.2, 2.6], [-10.2, 2.6]]),
...sideAt(0),
}, "尾鳍平面");
part.feature("TailFin", { featureType: "Pad", profile: "FinSketch", length: 0.16, midplane: true }, "尾鳍");
part.sketch("TailRotorSketch", {
profileType: "Circle", parameters: { Radius: 0.9 }, ...stationAt(-10.6), position: [-10.6, 0.5, 1.9],
}, "尾桨截面");
part.feature("TailRotorPad", { featureType: "Pad", profile: "TailRotorSketch", length: 0.1 }, "尾桨");
// Rotor mast: keeps the disc attached to the fuselage roof (one solid) and
// gives the PolarPattern a real hub to turn about.
part.sketch("MastSketch", {
profileType: "Circle", parameters: { Radius: 0.28 }, position: [0.4, 0, 1.4],
}, "旋翼轴截面");
part.feature("RotorMast", { featureType: "Pad", profile: "MastSketch", length: 0.5 }, "旋翼轴");
// Main rotor: one blade, then a four-blade PolarPattern about Z.
part.sketch("BladeSketch", {
profileType: "Geometry", ...band(0, 0, rotorSpan, 0.36, 0), position: [0.4, 0, 1.85],
}, "主旋翼叶片");
part.feature("BladePad", { featureType: "Pad", profile: "BladeSketch", length: 0.07 }, "主旋翼叶片");
part.transform("RotorPattern", {
transformType: "PolarPattern", originals: ["BladePad"],
rotationAxis: Z_AXIS, angle: 360, occurrences: 4,
}, "四叶旋翼");
void rotation;
}
export const helicopters = [
{ document: "CarrierHelicopterA", builder: "aircraft", build: part => buildHelicopter(part, { rotorSpan: 12 }) },
{ document: "CarrierHelicopterB", builder: "aircraft", build: part => buildHelicopter(part, { rotorSpan: 13 }) },
];

View File

@@ -0,0 +1,92 @@
// 飞行甲板(P02)与斜角甲板(P03)。
//
// The flight deck is a 333 m planform: parallel sides amidships, a swept bow,
// a square transom. It is a Pad from one plan sketch, then four elevator wells
// are cut as Pockets, then a row of tie-down fittings is patterned along the
// deck, then the well edges are chamfered -- Pad, Pocket, LinearPattern and
// Chamfer, the four feature kinds the legacy Part-workbench model could not
// express, and the reason the deck is the first trial part of the toolkit.
//
// The angled deck (P03) is a separate strip, like the real ship where it is a
// distinct structure cantilevered over the port side.
import { polygon, band } from "../lib/sketch.mjs";
export const document = "CarrierDeck";
export const builder = "deck";
const DECK_Z = 24;
const DECK_T = 1.5;
// Flight-deck planform, 333 m x 78 m.
const PLAN = [
[-166.5, -39], [-166.5, 39],
[-120, 39], [-60, 39], [0, 39], [60, 38],
[110, 33], [150, 22], [166.5, 8],
[166.5, -8], [150, -22], [110, -33],
[60, -38], [0, -39], [-60, -39], [-120, -39],
];
// Elevator wells: 20 m x 14 m, two rows of two aft of the island.
const WELLS = [
[-20, 26], [-20, -26], [-62, 26], [-62, -26],
];
export function build(part) {
part.sketch("DeckPlan", {
profileType: "Geometry", ...polygon(PLAN), position: [0, 0, DECK_Z],
}, "甲板平面");
part.feature("DeckPad", { featureType: "Pad", profile: "DeckPlan", length: DECK_T }, "甲板板");
const pockets = [];
for (const [x, y] of WELLS) {
const sketch = part.name("WellSketch");
// 20 m along x, 14 m along y, centred on the well.
part.sketch(sketch, {
profileType: "Geometry",
...polygon([[x - 10, y - 7], [x + 10, y - 7], [x + 10, y + 7], [x - 10, y + 7]]),
position: [0, 0, DECK_Z],
}, `升降机井口 (${x}, ${y})`);
const pocket = part.name("WellPocket");
part.feature(pocket, { featureType: "Pocket", profile: sketch, length: DECK_T }, `切除井口 ${pocket}`);
pockets.push(pocket);
}
// The chamfer must come before the fittings: setDressUp sets the body Tip to
// the dress-up feature, so anything added afterwards is chained on top of it.
// With the fittings last, the Tip is the pattern and the final body shape
// really contains all 12 padeyes.
part.dressUp("DeckEdgeChamfer", {
dressUpType: "Chamfer", base: pockets.at(-1), size: 0.25, useAllEdges: true,
}, "井口边缘倒角");
// Tie-down fittings: one 1.2 m padeye on the centre lane (y=14 keeps clear
// of the elevator wells at y=19..33), then a LinearPattern along the ship's
// X axis copies it 12 times over 220 m. The pad starts 0.1 m inside the deck
// (z=25.4, thickness 0.25) so the fuse overlaps instead of resting on a
// coplanar face.
part.sketch("FittingSketch", {
profileType: "Geometry",
...polygon([[-110.6, 13.4], [-109.4, 13.4], [-109.4, 14.6], [-110.6, 14.6]]),
position: [0, 0, DECK_Z + DECK_T - 0.1],
}, "系留桩平面");
part.feature("FittingPad", {
featureType: "Pad", profile: "FittingSketch", length: 0.25,
}, "系留桩");
part.transform("FittingPattern", {
transformType: "LinearPattern", originals: ["FittingPad"],
direction: { object: "X_Axis", subelements: [""] },
length: 220, occurrences: 12,
}, "系留桩阵列");
}
export const angledDeck = {
document: "CarrierAngledDeck",
builder: "deck",
build(part) {
// 240 m strip at 8 deg to port, 24 m wide, 1.2 m thick.
part.sketch("AngledPlan", {
profileType: "Geometry", ...band(-40, -24, 240, 24, 8), position: [0, 0, DECK_Z],
}, "斜角甲板平面");
part.feature("AngledPad", { featureType: "Pad", profile: "AngledPlan", length: 1.2 }, "斜角甲板");
},
};

View File

@@ -0,0 +1,74 @@
// 航空保障:升降机(P06)、弹射器(P07)、拦阻索(P08)。
//
// Three thin structures that only read correctly in plan: the four elevator
// platforms fill the deck wells, the four catapult tracks run bow and waist,
// and the arrestor wires cross the angled deck aft. All of them are built in
// ship coordinates, so the assembly places them at identity.
import { band } from "../lib/sketch.mjs";
const DECK_Z = 24;
const DECK_TOP = DECK_Z + 1.5;
// Elevator well centres, matching parts/deck.mjs.
const WELLS = [
[-20, 26], [-20, -26], [-62, 26], [-62, -26],
];
export const elevators = {
document: "CarrierElevators",
builder: "handling",
build(part) {
for (const [x, y] of WELLS) {
const sketch = part.name("ElevatorSketch");
part.sketch(sketch, {
profileType: "Geometry", ...band(x, y, 20, 14, 0), position: [0, 0, DECK_Z + 0.2],
}, `升降机平台 (${x}, ${y})`);
part.feature(part.name("ElevatorPad"), {
featureType: "Pad", profile: sketch, length: 0.9,
}, "升降机平台");
}
},
};
// Bow cats run fore-aft; waist cats sit at an angle to port, as on the real deck.
const CATS = [
{ x: 118, y: 14, length: 88, angle: 0 },
{ x: 118, y: -14, length: 88, angle: 0 },
{ x: 8, y: 24, length: 76, angle: 0 },
{ x: -30, y: -28, length: 78, angle: 8 },
];
export const catapults = {
document: "CarrierCatapults",
builder: "handling",
build(part) {
for (const cat of CATS) {
const sketch = part.name("CatapultSketch");
part.sketch(sketch, {
profileType: "Geometry",
...band(cat.x, cat.y, cat.length, 3, cat.angle),
position: [0, 0, DECK_TOP],
}, `弹射轨道 (${cat.x}, ${cat.y})`);
part.feature(part.name("CatapultPad"), {
featureType: "Pad", profile: sketch, length: 0.35,
}, "弹射轨道");
}
},
};
// Four wires across the angled deck, 6 m apart.
export const arrestorWires = {
document: "CarrierArrestorWires",
builder: "handling",
build(part) {
for (const x of [-150, -144, -138, -132]) {
const sketch = part.name("WireSketch");
part.sketch(sketch, {
profileType: "Geometry", ...band(x, -18, 56, 0.45, 90), position: [0, 0, DECK_TOP + 0.6],
}, `拦阻索 x=${x}`);
part.feature(part.name("WirePad"), {
featureType: "Pad", profile: sketch, length: 0.25,
}, "拦阻索");
}
},
};

View File

@@ -0,0 +1,30 @@
// 机库(P05):外壳 Pad + 内腔 Pocket。
//
// The hangar deck sits under the flight deck (z 8-24) and is the void the
// elevators open into. Shell first, cavity second. The Pocket needs no
// `reversed` flag: PartDesign::Pocket negates the sketch normal before
// extruding (FeaturePocket::getProfileNormal, App/FeaturePocket.cpp:134-138),
// so the default direction already cuts down into the solid. Reversing it
// would extrude out of the deck and remove nothing.
import { polygon, rectPoints } from "../lib/sketch.mjs";
export const document = "CarrierHangar";
export const builder = "hangar";
export function build(part) {
part.sketch("HangarShellSketch", {
profileType: "Geometry",
...polygon(rectPoints(-40, 0, 200, 34)),
position: [0, 0, 8],
}, "机库外壳平面");
part.feature("HangarShell", { featureType: "Pad", profile: "HangarShellSketch", length: 16 }, "机库外壳");
part.sketch("HangarCavitySketch", {
profileType: "Geometry",
...polygon(rectPoints(-40, 0, 190, 28)),
position: [0, 0, 24],
}, "机库内腔平面");
part.feature("HangarCavity", {
featureType: "Pocket", profile: "HangarCavitySketch", length: 13,
}, "掏空内腔");
}

View File

@@ -0,0 +1,71 @@
// 舰体(P01):9 个横剖面草图 + 放样。
//
// The hull is the one part whose realism cannot come from boxes: a carrier is a
// slender body with a fine bow and a transom stern, and the shape lives in the
// changing cross-section. Nine stations are enough for a smooth loft at this
// scale (333 m), and every station uses the same 13-point half-section mirrored
// about the centreline so OCCT never has to guess how two sections correspond.
//
// Station sketch plane: world YZ at `x` (lib/sketch.mjs stationAt), local
// (u, v) = (height, beam). Loft sections must be distinct sketches in order,
// which is exactly what the kernel validates (PartDesignDocumentWorkflow.cpp
// setFeature, Loft branch).
import { polygon, stationAt } from "../lib/sketch.mjs";
export const document = "CarrierHull";
export const builder = "hull";
// x, half-beam at deck level. Bow 1.5 m, transom 9 m: a 333 m hull.
const STATIONS = [
[-166.5, 9],
[-150, 15],
[-120, 19],
[-60, 21],
[0, 21],
[60, 20],
[110, 16],
[145, 10],
[166.5, 1.5],
];
const DECK = 24;
/** One closed half-section mirrored about y=0, in (height, beam) order. */
function section(half) {
const top = half * 0.86;
return [
[0, 0],
[0.8, half * 0.55],
[3, half * 0.85],
[8, half * 0.97],
[14, half],
[20, half * 0.98],
[DECK, top],
[DECK, -top],
[20, -half * 0.98],
[14, -half],
[8, -half * 0.97],
[3, -half * 0.85],
[0.8, -half * 0.55],
];
}
export function build(part) {
const names = [];
for (const [x, half] of STATIONS) {
const name = part.name("HullSketch");
const shape = polygon(section(half));
part.sketch(name, { profileType: "Geometry", ...shape, ...stationAt(x) }, `横剖面 x=${x}`);
names.push(name);
}
// Loft keeps the first station as its Profile and the rest as Sections
// (PartDesign::Loft is ProfileBased): the kernel rejects a section that is
// the profile itself, so pass names.slice(1).
part.feature("HullLoft", {
featureType: "Loft",
profile: names[0],
sections: names.slice(1),
ruled: false,
closed: false,
}, "舰体放样");
}

View File

@@ -0,0 +1,51 @@
// Registry: every carrier PartDesign document, in build order.
//
// The ids match spec.json and the teaching console lessons. P01-P10 are the
// ship herself (built in ship coordinates, placed at identity); P11-P19 are
// airframes in local coordinates; P20 is deck paint.
import * as hull from "./hull.mjs";
import * as deck from "./deck.mjs";
import * as island from "./island.mjs";
import * as hangar from "./hangar.mjs";
import * as handling from "./handling.mjs";
import * as sensors from "./sensors.mjs";
import { fighters, awacs, helicopters } from "./aircraft.mjs";
import * as markings from "./markings.mjs";
const fighterById = Object.fromEntries(
["P11", "P12", "P13", "P14", "P15", "P16"].map((id, index) => [id, fighters[index]]),
);
const byDocument = [
["P01", hull],
["P02", deck],
["P03", deck.angledDeck],
["P04", island],
["P05", hangar],
["P06", handling.elevators],
["P07", handling.catapults],
["P08", handling.arrestorWires],
["P09", sensors.radar],
["P10", sensors.ciws],
["P11", fighterById.P11],
["P12", fighterById.P12],
["P13", fighterById.P13],
["P14", fighterById.P14],
["P15", fighterById.P15],
["P16", fighterById.P16],
["P17", awacs],
["P18", helicopters[0]],
["P19", helicopters[1]],
["P20", markings],
];
export const parts = byDocument.map(([id, module]) => ({
id,
document: module.document,
builder: module.builder,
build: module.build,
}));
export function partFor(key) {
return parts.find(part => part.id === key || part.document === key) ?? null;
}

View File

@@ -0,0 +1,61 @@
// 舰岛(P04):塔式分层结构。
//
// A carrier island is a stack of shrinking decks -- base, tower, bridge -- with
// a funnel aft and a mast on top. Each tier is its own plan sketch on its own
// plane, which is how the real structure is drawn: no boolean of boxes, just
// four Pads anchored at rising heights. The bridge top gets a Chamfer so the
// silhouette is not a raw extrusion.
import { polygon, rectPoints, circle } from "../lib/sketch.mjs";
export const document = "CarrierIsland";
export const builder = "island";
const DECK_Z = 24;
// Starboard side, slightly aft of midships.
const CX = -4;
const CY = 28;
const TIERS = [
{ name: "IslandBase", cx: CX, cy: CY, w: 36, h: 14, z: DECK_Z, t: 12 },
{ name: "IslandTower", cx: CX + 2, cy: CY, w: 28, h: 12, z: DECK_Z + 12, t: 10 },
{ name: "IslandBridge", cx: CX + 4, cy: CY, w: 18, h: 10, z: DECK_Z + 22, t: 7 },
];
export function build(part) {
let last = null;
for (const tier of TIERS) {
const sketch = part.name("IslandSketch");
part.sketch(sketch, {
profileType: "Geometry",
...polygon(rectPoints(tier.cx, tier.cy, tier.w, tier.h)),
position: [0, 0, tier.z],
}, `${tier.name} 平面 z=${tier.z}`);
part.feature(tier.name, { featureType: "Pad", profile: sketch, length: tier.t }, `塔体 ${tier.name}`);
last = tier.name;
}
// Funnel: a 7 x 6 m uptake on the base, aft of the tower.
part.sketch("FunnelSketch", {
profileType: "Geometry",
...polygon(rectPoints(CX - 17, CY, 7, 6)),
position: [0, 0, DECK_Z],
}, "烟囱平面");
part.feature("IslandFunnel", { featureType: "Pad", profile: "FunnelSketch", length: 18 }, "烟囱");
// Mast: 1.3 m radius tube rising 14 m above the bridge.
part.sketch("MastSketch", {
profileType: "Circle",
parameters: { Radius: 1.3 },
position: [CX - 8, CY, DECK_Z + 29],
}, "桅杆截面");
part.feature("IslandMast", { featureType: "Pad", profile: "MastSketch", length: 14 }, "桅杆");
// 0.25 m survives the fused tier stack; 0.5 m makes OCCT fail the chamfer on
// the short edges where the mast meets the bridge (measured, probe run
// 2026-11-25: size=0.5 -> BRep_API command not done, 0.25/0.12 -> done).
part.dressUp("BridgeChamfer", {
dressUpType: "Chamfer", base: last, size: 0.25, useAllEdges: true,
}, "舰桥顶倒角");
void circle;
}

View File

@@ -0,0 +1,38 @@
// 甲板标线(P20):中心线、降落区框、甲板边缘线。
//
// Paint is geometry in PartDesign too: each marking is a 3 cm Pad sitting on
// the flight deck. The landing-area frame is one sketch made of four merged
// bands, so the whole frame is a single feature rather than four.
import { band, merge } from "../lib/sketch.mjs";
export const document = "CarrierMarkings";
export const builder = "markings";
const TOP = 25.5;
const PAINT = 0.03;
export function build(part) {
part.sketch("CenterlineSketch", {
profileType: "Geometry", ...band(0, 0, 320, 0.9, 0), position: [0, 0, TOP],
}, "甲板中心线");
part.feature("CenterlinePad", { featureType: "Pad", profile: "CenterlineSketch", length: PAINT }, "中心线");
// Landing area frame: 200 m long, 32 m wide, centred at x = -40.
const frame = merge(
band(-40, 16, 200, 0.6, 0),
band(-40, -16, 200, 0.6, 0),
band(-140, 0, 32.6, 0.6, 90),
band(60, 0, 32.6, 0.6, 90),
);
part.sketch("LandingFrameSketch", {
profileType: "Geometry", ...frame, position: [0, 0, TOP],
}, "降落区边框");
part.feature("LandingFramePad", { featureType: "Pad", profile: "LandingFrameSketch", length: PAINT }, "降落区边框");
// Port and starboard deck-edge lines.
const edges = merge(band(0, 37, 300, 0.5, 0), band(0, -37, 300, 0.5, 0));
part.sketch("DeckEdgeSketch", {
profileType: "Geometry", ...edges, position: [0, 0, TOP],
}, "甲板边缘线");
part.feature("DeckEdgePad", { featureType: "Pad", profile: "DeckEdgeSketch", length: PAINT }, "甲板边缘线");
}

View File

@@ -0,0 +1,68 @@
// 传感与武器:相控阵雷达(P09)与近防炮(P10)。
//
// The radar is a pedestal, a flat array face and a back frame; the CIWS is a
// local-coordinate mount (base, housing, two barrels) that the assembly drops
// onto the starboard deck edge. Both keep every dimension in metres so the
// parts can be checked against the ship drawing.
import { polygon, rectPoints, circle } from "../lib/sketch.mjs";
const ISLAND_TOP = 53;
const RADAR_Y = 28;
export const radar = {
document: "CarrierRadar",
builder: "sensors",
build(part) {
// Pedestal drum on the bridge top.
part.sketch("RadarPedestalSketch", {
profileType: "Circle", parameters: { Radius: 2.2 }, position: [4, RADAR_Y, ISLAND_TOP],
}, "雷达基座截面");
part.feature("RadarPedestal", { featureType: "Pad", profile: "RadarPedestalSketch", length: 3 }, "雷达基座");
// Array face: 7 m wide, 5 m tall, 0.6 m thick, lookng forward.
part.sketch("RadarFaceSketch", {
profileType: "Geometry",
...polygon(rectPoints(4, ISLAND_TOP + 5.5, 7, 5)),
position: [0, RADAR_Y, 0],
placementRotation: [Math.SQRT1_2, 0, 0, Math.SQRT1_2],
}, "阵面草图");
part.feature("RadarFace", { featureType: "Pad", profile: "RadarFaceSketch", length: 0.6 }, "相控阵面");
// Back frame so the array does not look like a floating card.
part.sketch("RadarFrameSketch", {
profileType: "Circle", parameters: { Radius: 0.6 }, position: [4, RADAR_Y + 0.9, ISLAND_TOP + 3],
}, "阵面支架截面");
part.feature("RadarFrame", { featureType: "Pad", profile: "RadarFrameSketch", length: 2.4 }, "阵面支架");
void circle;
},
};
export const ciws = {
document: "CarrierCiws",
builder: "sensors",
build(part) {
// Local origin at the deck contact point.
part.sketch("CiwsBaseSketch", {
profileType: "Circle", parameters: { Radius: 2.6 }, position: [0, 0, 0],
}, "炮座截面");
part.feature("CiwsBase", { featureType: "Pad", profile: "CiwsBaseSketch", length: 1.4 }, "炮座");
part.sketch("CiwsHousingSketch", {
profileType: "Geometry", ...polygon(rectPoints(0, 0, 4.4, 2.6)), position: [0, 0, 1.4],
}, "炮塔壳体");
part.feature("CiwsHousing", { featureType: "Pad", profile: "CiwsHousingSketch", length: 2.2 }, "炮塔壳体");
// Two barrels along +X, 1.4 m apart.
for (const y of [-0.7, 0.7]) {
const sketch = part.name("BarrelSketch");
part.sketch(sketch, {
profileType: "Circle", parameters: { Radius: 0.22 },
position: [2.2, y, 2.4],
placementRotation: [0, Math.SQRT1_2, 0, Math.SQRT1_2],
}, `炮管截面 y=${y}`);
part.feature(part.name("BarrelPad"), {
featureType: "Pad", profile: sketch, length: 3.6,
}, "炮管");
}
},
};

View File

@@ -0,0 +1,71 @@
{
"schema": "freecad-web-carrier-partdesign-spec/v1",
"title": "航空母舰 PartDesign 建件清单",
"units": "m",
"dimensions": { "length": 333, "beam": 78, "height": 67, "draft": 12, "displacementT": 98257 },
"systems": {
"hull-structure": "舰体结构",
"angled-deck": "斜角甲板",
"flight-deck": "飞行甲板",
"island": "舰岛上层建筑",
"hangar": "机库",
"aircraft-handling": "航空保障(升降机/弹射器/拦阻索)",
"sensors": "雷达与传感",
"weapons": "近防武器",
"air-fighter": "舰载战斗机",
"air-awacs": "舰载预警机",
"air-rotor": "舰载直升机",
"markings": "甲板标线"
},
"parts": [
{ "id": "P01", "document": "CarrierHull", "title": "舰体", "system": "hull-structure",
"module": "parts/hull.mjs", "featureTypes": ["Loft"] },
{ "id": "P02", "document": "CarrierDeck", "title": "飞行甲板", "system": "flight-deck",
"module": "parts/deck.mjs", "featureTypes": ["Pad", "Pocket", "Chamfer"] },
{ "id": "P03", "document": "CarrierAngledDeck", "title": "斜角甲板", "system": "angled-deck",
"module": "parts/deck.mjs", "featureTypes": ["Pad"] },
{ "id": "P04", "document": "CarrierIsland", "title": "舰岛", "system": "island",
"module": "parts/island.mjs", "featureTypes": ["Pad", "Chamfer"] },
{ "id": "P05", "document": "CarrierHangar", "title": "机库", "system": "hangar",
"module": "parts/hangar.mjs", "featureTypes": ["Pad", "Pocket"] },
{ "id": "P06", "document": "CarrierElevators", "title": "升降机", "system": "aircraft-handling",
"module": "parts/handling.mjs", "featureTypes": ["Pad"], "placement": { "position": [0, 0, 0], "heading": 0 } },
{ "id": "P07", "document": "CarrierCatapults", "title": "弹射器", "system": "aircraft-handling",
"module": "parts/handling.mjs", "featureTypes": ["Pad"], "placement": { "position": [0, 0, 0], "heading": 0 } },
{ "id": "P08", "document": "CarrierArrestorWires", "title": "拦阻索", "system": "aircraft-handling",
"module": "parts/handling.mjs", "featureTypes": ["Pad"], "placement": { "position": [0, 0, 0], "heading": 0 } },
{ "id": "P09", "document": "CarrierRadar", "title": "相控阵雷达", "system": "sensors",
"module": "parts/sensors.mjs", "featureTypes": ["Pad"], "placement": { "position": [0, 0, 0], "heading": 0 } },
{ "id": "P10", "document": "CarrierCiws", "title": "近防炮", "system": "weapons",
"module": "parts/sensors.mjs", "featureTypes": ["Pad"], "placement": { "position": [60, 28, 25.5], "heading": 0 } },
{ "id": "P11", "document": "CarrierFighterA", "title": "舰载战斗机 A", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [-60, 20, 25.5], "heading": 0 } },
{ "id": "P12", "document": "CarrierFighterB", "title": "舰载战斗机 B", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [-60, -20, 25.5], "heading": 0 } },
{ "id": "P13", "document": "CarrierFighterC", "title": "舰载战斗机 C", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [-100, 20, 25.5], "heading": 0 } },
{ "id": "P14", "document": "CarrierFighterD", "title": "舰载战斗机 D", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [-100, -20, 25.5], "heading": 0 } },
{ "id": "P15", "document": "CarrierFighterE", "title": "舰载战斗机 E", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [30, 24, 25.5], "heading": 45 } },
{ "id": "P16", "document": "CarrierFighterF", "title": "舰载战斗机 F", "system": "air-fighter",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [62, -20, 25.5], "heading": 180 } },
{ "id": "P17", "document": "CarrierAwacs", "title": "舰载预警机", "system": "air-awacs",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "Mirrored"],
"placement": { "position": [105, 0, 25.5], "heading": 0 } },
{ "id": "P18", "document": "CarrierHelicopterA", "title": "舰载直升机 A", "system": "air-rotor",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "PolarPattern"],
"placement": { "position": [-130, 18, 25.5], "heading": 0 } },
{ "id": "P19", "document": "CarrierHelicopterB", "title": "舰载直升机 B", "system": "air-rotor",
"module": "parts/aircraft.mjs", "featureTypes": ["Revolution", "Pad", "PolarPattern"],
"placement": { "position": [-130, -18, 25.5], "heading": 0 } },
{ "id": "P20", "document": "CarrierMarkings", "title": "甲板标线", "system": "markings",
"module": "parts/markings.mjs", "featureTypes": ["Pad"], "placement": { "position": [0, 0, 0], "heading": 0 } }
]
}

File diff suppressed because one or more lines are too long

View File

@@ -216,7 +216,7 @@
</li>
</ol>
<p><a class="cta" href="runner.html">打开可视化执行页</a><a class="cta" href="console.html">打开教学控制台(按工作台课程在线运行真实用例)</a><a class="cta secondary" href="features.html">查看 32 个模块的功能列表</a><a class="cta" href="cases/engine-block.html">案例教学:4 缸发动机缸体</a><a class="cta secondary" href="cases/t1-replica.html">案例教学:照 t1.stp 复刻零件</a><a class="cta secondary" href="cases/secondary-reducer.html">案例教学:二级齿轮减速器(界面操作)</a><a class="cta" href="cases/reducer-course.html">视频课程:二级减速器生产级建模(12 集)</a><a class="cta secondary" href="reducer-manual.html">初学者手册:二级减速器</a><a class="cta" href="cases/reducer-replay.html">过程可视化:二级减速器建模回放(24 件 + 装配)</a><a class="cta" href="cases/reducer-parts-course.html">逐零件建模过程视频(23 集 + 中文配音)</a><a class="cta secondary" href="reducer-parts-manual.html">零件设计入门:图文教案(14 章)</a><a class="cta" href="fcweb-toolkit.html">工具库:建零件与装配的通用工具(API 指南)</a><a class="cta secondary" href="reducer-toolkit.html">工具:有头创建二级减速器(按零件分步 + 初学者讲义)</a><a class="cta" href="cases/assembly-tolerance.html">案例教学:装配公差分析(初学者)</a><a class="cta" href="cases/cam-teaching.html">案例教学:三轴 CAM(初学者)</a><a class="cta" href="cases/carrier.html">案例教学:航空母舰(含培训视频)</a><a class="cta" href="cases/fem-cantilever.html">案例教学:FEM 悬臂梁(应力云图)</a><a class="cta" href="cases/production-line.html">案例教学:三维产线(有头界面 + MCP)</a><a class="cta" href="cases/abb120-line.html">案例教学:ABB IRB 120 产线(MCP)</a><a class="cta" href="cases/production-line-course.html">视频课程:27 件 GLB 产线建模(18 集)</a><a class="cta secondary" href="z-up-verification.html">Three.js Z-up 验证报告</a><a class="cta" href="http://127.0.0.1:5180/bim-workshop.html">BIM 厂房车间(30×18m)</a><a class="cta secondary" href="bim-workshop-tutorial.html">BIM 厂房教程</a><a class="cta secondary" href="bim-workshop-manual.html">BIM 厂房初学者手册(视频)</a><a class="cta secondary" href="http://127.0.0.1:5180/workbench.html?module=Inspection&amp;command=inspection.createRecompute" target="_blank" rel="noopener">直接打开这条案例</a></p>
<p><a class="cta" href="runner.html">打开可视化执行页</a><a class="cta" href="console.html">打开教学控制台(按工作台课程在线运行真实用例)</a><a class="cta secondary" href="features.html">查看 32 个模块的功能列表</a><a class="cta" href="cases/engine-block.html">案例教学:4 缸发动机缸体</a><a class="cta secondary" href="cases/t1-replica.html">案例教学:照 t1.stp 复刻零件</a><a class="cta secondary" href="cases/secondary-reducer.html">案例教学:二级齿轮减速器(界面操作)</a><a class="cta" href="cases/reducer-course.html">视频课程:二级减速器生产级建模(12 集)</a><a class="cta secondary" href="reducer-manual.html">初学者手册:二级减速器</a><a class="cta" href="cases/reducer-replay.html">过程可视化:二级减速器建模回放(24 件 + 装配)</a><a class="cta" href="cases/reducer-parts-course.html">逐零件建模过程视频(23 集 + 中文配音)</a><a class="cta secondary" href="reducer-parts-manual.html">零件设计入门:图文教案(14 章)</a><a class="cta" href="fcweb-toolkit.html">工具库:建零件与装配的通用工具(API 指南)</a><a class="cta secondary" href="reducer-toolkit.html">工具:有头创建二级减速器(按零件分步 + 初学者讲义)</a><a class="cta" href="cases/assembly-tolerance.html">案例教学:装配公差分析(初学者)</a><a class="cta" href="cases/cam-teaching.html">案例教学:三轴 CAM(初学者)</a><a class="cta" href="cases/carrier.html">案例教学:航空母舰(含培训视频)</a><a class="cta secondary" href="carrier-toolkit.html">工具:有头创建航空母舰(20 件 PartDesign + 装配)</a><a class="cta" href="cases/fem-cantilever.html">案例教学:FEM 悬臂梁(应力云图)</a><a class="cta" href="cases/production-line.html">案例教学:三维产线(有头界面 + MCP)</a><a class="cta" href="cases/abb120-line.html">案例教学:ABB IRB 120 产线(MCP)</a><a class="cta" href="cases/production-line-course.html">视频课程:27 件 GLB 产线建模(18 集)</a><a class="cta secondary" href="z-up-verification.html">Three.js Z-up 验证报告</a><a class="cta" href="http://127.0.0.1:5180/bim-workshop.html">BIM 厂房车间(30×18m)</a><a class="cta secondary" href="bim-workshop-tutorial.html">BIM 厂房教程</a><a class="cta secondary" href="bim-workshop-manual.html">BIM 厂房初学者手册(视频)</a><a class="cta secondary" href="http://127.0.0.1:5180/workbench.html?module=Inspection&amp;command=inspection.createRecompute" target="_blank" rel="noopener">直接打开这条案例</a></p>
</section>
<section id="gallery">

View File

@@ -35,6 +35,8 @@ const PROBE_ENTRY = path.join(REPO_ROOT, "tools/layout-probe.mjs");
const HOST_ENTRY = path.join(REPO_ROOT, "tools/static-host.mjs");
const REDUCER_PART = path.join(REPO_ROOT, "tools/reducer/create-part.mjs");
const REDUCER_ASSEMBLY = path.join(REPO_ROOT, "tools/reducer/create-assembly.mjs");
const CARRIER_PART = path.join(REPO_ROOT, "tools/carrier/create-part.mjs");
const CARRIER_ASSEMBLY = path.join(REPO_ROOT, "tools/carrier/create-assembly.mjs");
const LINE_LIMIT = 2000;
const BYTE_LIMIT = 512 * 1024;
@@ -47,6 +49,10 @@ const TIMEOUTS = {
// A 26-step cover part takes ~10 min headed; leave room without hanging forever.
"reducer-part": 40 * 60_000,
"reducer-assembly": 45 * 60_000,
// Carrier parts are heavier (deck chamfers and lofts compute for tens of
// seconds each); the 14-step deck measured ~9.5 min headed.
"carrier-part": 45 * 60_000,
"carrier-assembly": 60 * 60_000,
};
export class JobError extends Error {
@@ -209,6 +215,17 @@ export function buildJobArgv(lesson, params = {}, { jobDir } = {}) {
if (job.kind === "reducer-assembly") {
return { argv: [process.execPath, REDUCER_ASSEMBLY, "--out", jobDir, "--json"], dir: jobDir };
}
if (job.kind === "carrier-part") {
const partId = String(job.partId ?? "");
if (!/^P\d{2}$/.test(partId)) throw new JobError("E_PARAM", `非法零件编号:${partId.slice(0, 20)}`);
const argv = [process.execPath, CARRIER_PART, partId];
if (job.dry) argv.push("--dry");
argv.push("--out", jobDir, "--json");
return { argv, dir: jobDir };
}
if (job.kind === "carrier-assembly") {
return { argv: [process.execPath, CARRIER_ASSEMBLY, "--out", jobDir, "--json"], dir: jobDir };
}
throw new JobError("E_PARAM", `未知课程类型:${job.kind}`);
}
@@ -389,6 +406,35 @@ export function createRunner({ root = CONSOLE_ROOT } = {}) {
else if (job.timedOut) job.verdict = "timeout";
else if (!report) job.verdict = code === 2 ? "precondition_fail" : "run_fail";
else job.verdict = report.verdict;
} else if (job.kind === "carrier-part" || job.kind === "carrier-assembly") {
const report = readJson(path.join(job.dir, "report.json")).value;
const isPart = job.kind === "carrier-part";
const label = isPart ? (report?.part?.id ?? "part") : (report?.document ?? "assembly");
job.progress = {
...job.progress,
planned: 1,
completed: 1,
results: report ? [{
id: label,
title: isPart ? (report.part?.title ?? report.part?.document ?? "零件")
: (report.label ?? "装配"),
status: report.verdict === "pass" ? "passed" : report.verdict === "product_fail" ? "failed" : "blocked",
seconds: report.seconds ?? null,
// Distinguish "the geometry differs" from "nothing ran at all": the
// first is a product regression, the second a broken precondition.
error: report.verdict === "product_fail"
? (isPart && report.volumeMatches === false
? `体积 ${report.volume} ≠ 记录 ${report.expectedVolume}`
: (isPart
? `有步骤失败:${report.steps}/${report.stepsTotal} 步完成`
: `插入 ${report.inserted},关节 ${report.joints},畸形组件 ${report.malformedComponents}`))
: (report.fatal ?? null),
}] : [],
};
if (job.cancelled) job.verdict = "cancelled";
else if (job.timedOut) job.verdict = "timeout";
else if (!report) job.verdict = code === 2 ? "precondition_fail" : "run_fail";
else job.verdict = report.verdict;
} else if (job.kind === "host") {
// The host lesson succeeds once ORIGIN is printed; an explicit user
// cancel still reads as cancelled even if that already happened.
@@ -446,6 +492,7 @@ export function createRunner({ root = CONSOLE_ROOT } = {}) {
lines: [], bytes: 0, partial: { stdout: "", stderr: "" },
progress: {
planned: entry.job.kind === "reducer-part" || entry.job.kind === "reducer-assembly"
|| entry.job.kind === "carrier-part" || entry.job.kind === "carrier-assembly"
? 1
: entry.job.selectable ? (params.only?.length ?? 0) : (entry.job.only?.length ?? 0),
completed: 0, current: null, counts: null, results: [],

View File

@@ -0,0 +1,151 @@
# cad-ui-rebuild · 在真实界面上重建 CAD 模型
把一个已经建好的 FreeCAD 工程**在 Web FreeCAD 的真实界面上一步一步重做一遍**,
并证明重做结果与原始模型数值一致。用于:
- 给工程生成「照着点就能做出来」的界面操作说明与截图;
- 回归验证界面没有退化(同样的输入必须得到同样的体积);
- 培训材料,每一帧都是真实界面而不是示意图。
## 它做什么
对工程里的每个零件:
1. `build-steps` — 从该零件的构建记录 + 成品 FCStd 抽出**每一步的界面参数**
(草图几何、约束、特征参数、位置、朝向)。
2. `drive` — 打开浏览器,像人一样逐步点按钮、填字段,每步截一张图,
并把界面算出的体积与构建记录比对。
3. `assemble` — 新建装配体,把每个零件按位置和旋转插入。
4. `accept` — 只读证据文件,判定上面三步是否真的成立。
## 三步接入一个新工程
### 1. 准备数据
工程目录里需要:
```
<project>/
project.json ← 唯一手写的文件,见下
project.json.paths.replayDir/ <零件名>.json 每个零件的构建记录
.../sampleDir/ <零件名>.FCStd 成品文件
```
构建记录的每一步形如:
```json
{ "step": 3, "label": "outer pad", "action": "setFeature",
"args": { "object": "HousingBlock", "featureType": "Pad",
"profile": "OuterProfile", "length": 260, "midplane": false },
"volume": 26885040 }
```
`action` 支持 `setSketch` / `setFeature` / `setGear` / `setPrimitive` / `setTransform`。
### 2. 写 `project.json`
```json
{
"schema": "freecad-web-cad-ui-rebuild/project/v1",
"name": "my-project",
"appOrigin": "http://127.0.0.1:5180",
"paths": {
"replayDir": "replays",
"sampleDir": "samples",
"outDir": "out",
"stillsDir": "ui-stills"
},
"parts": [
{ "id": "P01", "document": "MyPart", "title": "我的零件" }
],
"assembly": { "document": "MyAssembly", "groundDocument": "MyPart" }
}
```
- `paths.replayName`:记录文件名模式,`{document}` 会被替换。默认 `<document>.json`;
记录另有命名的工程写 `"replayName": "trace-{document}.json"` 即可,不必改代码。
- `paths.outDir` / `stillsDir`:产物位置,相对清单所在目录。
- `pages`:每种命令在哪个页面。默认全部 `partdesign.html`(唯一同时有草图和特征的面板)。
- `featureCommands`:特征类型到命令名的映射。默认已含 Pad/Pocket/Revolution/Groove。
- `assembly` 可省略;省略则 `assemble.mjs` 与装配验收自动跳过。
### 3. 跑
```bash
T=/home/mes123456/FreeCADWasmDev/working/FreeCAD/web/tools/cad-ui-rebuild
node $T/build-steps.mjs --project <project> # 生成 out/ui-steps/
$T/sweep.sh --project <project> # 逐件驱动,产物在 out/ui-run/ 与 ui-stills/
node $T/assemble.mjs --project <project> # 可选:装配
node $T/accept.mjs --project <project> # 验收
```
**想看着它做**:给 `drive.mjs` 加 `--headed`(再加 `--slow` 放慢)。
界面会出现在 `DISPLAY` 指定的显示器上。
## 前置条件(不满足时先补,不要当作产品失败)
| 前置 | 怎么确认 |
|---|---|
| 应用在线 | `curl -s -o /dev/null -w '%{http_code}' $appOrigin/` 应为 `200` |
| 内核产物就位 | `web/public/kernel/FreeCADWebPartDesignRuntimeProbe.{js,wasm}` 存在 |
| 显示器非休眠 | `node capture-check.mjs --display :1` 输出 `"ok":true` |
| 磁盘有余量 | 探针要读 130 MB wasm + 解压;剩余空间不足会静默卡死 |
显示器休眠时抓屏全是黑的。`capture-check.mjs` 用**均值 + 唯一颜色数**双判,
因为休眠时残留的鼠标像素会让单看最大值的判据误判为正常。
## 输出
| 文件 | 内容 |
|---|---|
| `out/ui-steps/<document>.json` | 每步的完整界面参数 |
| `out/ui-run/<document>.json` | 每步的实际体积 vs 期望体积、耗时、失败原因 |
| `ui-stills/<id>/<scene>.png` | 每步一张真实界面截图 |
| `out/ui-run/<assembly>-assembly.json` | 插入次数、旋转值、与记录的差异 |
## 为什么要这些字段
**朝向 `placementRotation`**:草图不总在 XY 平面上。壳体上的螺栓孔画在
Y 方向的面上,键槽画在轴侧面。少这个字段,特征会"什么都没切",而体积只差几个百分点。
**圆弧角度精度**:`startAngle`/`endAngle` 是**弧度**。π 写成 `3.1416` 会让半径 41 的
圆弧端点偏 1.6e-4 mm,远超 OCCT 的 1e-7 容差,轮廓闭合不上,挖切只得到一层薄片。
本工具按 1e-9 保留。
**齿轮的 `position`**:齿轮表单的位置是独立的。不设就长在原点,与轴身重叠,
体积只差 6%,不报错。
## 现成的工程清单
`projects/` 下已放好两份可直接使用的清单(详见 `projects/README.md`),
覆盖仓库里现存的两代构建记录格式:
```bash
node build-steps.mjs --project projects/secondary-reducer-pro.json
node build-steps.mjs --project projects/secondary-reducer.json
```
## 已知边界
- 只覆盖**建模 + 装配**。视频、配音、教案流水线不在这里。
- `drive` 依赖中文界面文案(`新建文档`、`新建 Body`、`几何与约束`、`体积`)。
- 装配的创建与插入走界面任务面板;关节与求解仍走工作台表单,尚未提供纯界面路径。
## 装配为什么去 `workbench.html`
`assembly.html` 是内核装配探针的夹具页(`src/assembly-slice.ts` 发
`ASSEMBLY_*_FIXTURE` 请求,页面上那个 "Invalid type" 是它演示错误分支的按钮),
没有创建与插入面板。真正的面板由 `src/workbench-shell.tsx` 按命令挂载:
| 面板 | 地址 |
|---|---|
| Create assembly | `workbench.html?module=Assembly&command=Assembly_CreateAssembly` |
| Insert assembly link | `workbench.html?module=Assembly&command=Assembly_InsertLink` |
建完装配后插入面板自动挂出,无需再导航。需要把源 FCStd 放进 OPFS 的
**`freecad-documents`**(不是 `freecad-exports`;后者是 STEP/STL 等导出物)。
插入面板的候选对象用复合键 `documentId:object`:不同零件文档里的对象常同名
(减速器 23 件的实体都叫 `Body`),裸对象名作 option value 会让 23 个选项同值,
每次插入都命中第一个打开的文档,而且什么错都不报。

View File

@@ -0,0 +1,86 @@
#!/usr/bin/env node
// Verify a project's evidence without re-running the browser.
//
// This is the tool's own acceptance profile: it answers "was every modelling
// step actually performed through the UI, and did the UI produce the same
// numbers as the scripted build?" from files on disk only.
//
// Usage: node accept.mjs --project <dir>
import fs from "node:fs";
import path from "node:path";
import { loadProject, projectFromArgv, readJson, replayPath } from "./manifest.mjs";
import { readReplay } from "./lib/replay.mjs";
import { stillName } from "./lib/stills.mjs";
const projectDir = projectFromArgv();
const project = loadProject(projectDir, { requireParts: true });
const checks = [];
const check = (id, name, ok, detail) => checks.push({ id, name, ok: Boolean(ok), detail });
const missing = [];
const volumeMisses = [];
const stepMismatches = [];
const noStills = [];
let totalSteps = 0;
let partsSeen = 0;
for (const part of project.parts) {
const stepsFile = path.join(project.paths.stepsDir, `${part.document}.json`);
const runFile = path.join(project.paths.runDir, `${part.document}.json`);
const replay = project.paths.replayDir ? readReplay(replayPath(project, part.document)) : null;
if (!fs.existsSync(stepsFile)) { missing.push(`${part.id}: no ui-steps`); continue; }
partsSeen++;
const steps = readJson(stepsFile).steps ?? [];
totalSteps += steps.length;
if (replay && steps.length !== replay.steps.length)
stepMismatches.push(`${part.id}: ${steps.length} ui steps vs ${replay.steps.length} replay steps`);
for (const step of steps) if (!step.command) noStills.push(`${part.id} step ${step.step}: no command`);
// One still per step, named by the scene id the driver captured.
const dir = path.join(project.paths.stillsDir, part.id);
const files = fs.existsSync(dir) ? fs.readdirSync(dir).filter(name => name.endsWith(".png")) : [];
if (!files.length) noStills.push(`${part.id}: no stills directory`);
// Ask the same module the writer uses, so the checker cannot drift from it.
for (const [index, step] of steps.entries()) {
const stem = `${stillName(project, part, index, steps)}.png`;
if (!files.includes(stem)) noStills.push(`${part.id} ${step.label} (${stem})`);
}
if (!fs.existsSync(runFile)) { volumeMisses.push(`${part.id}: no ui-run evidence`); continue; }
const run = readJson(runFile);
if (!(run.steps === run.stepsTotal && run.failed === 0 && run.volumeMatches === true)) {
const detail = run.steps === run.stepsTotal
? `rel ${run.relativeError}` : `aborted at ${run.steps}/${run.stepsTotal ?? "?"}`;
volumeMisses.push(`${part.id}: ${detail}`);
}
}
check("U1", "每件都有界面步骤清单", missing.length === 0, { missing: missing.slice(0, 8) });
check("U2", "步骤数与回放一致且每步有命令", stepMismatches.length === 0 && noStills.every(item => !/no command/.test(item)),
{ totalSteps, parts: partsSeen, mismatches: stepMismatches.slice(0, 8) });
check("U3", "每步都有界面截图", noStills.filter(item => !/no command/.test(item)).length === 0,
{ missing: noStills.slice(0, 8) });
check("U4", "界面复现体积与回放一致(1e-6)", volumeMisses.length === 0, { failed: volumeMisses.slice(0, 8) });
if (project.assembly) {
const reportFile = path.join(project.paths.runDir, `${project.assembly.document}-assembly.json`);
if (!fs.existsSync(reportFile)) {
check("U5", "装配经界面完成", false, { error: `no assembly report at ${reportFile}` });
} else {
const report = readJson(reportFile);
check("U5", "装配插入完整且旋转保留",
!report.fatal && report.mismatches?.length === 0
&& report.inserted === report.expected?.inserts
&& report.rotated === report.expected?.rotated,
{ inserted: report.inserted, rotated: report.rotated, expected: report.expected,
mismatches: (report.mismatches ?? []).slice(0, 6), fatal: report.fatal });
}
}
const failed = checks.filter(item => !item.ok);
console.log(JSON.stringify({ passed: failed.length === 0, checks: checks.length, failed: failed.length,
results: checks.map(item => ({ id: item.id, ok: item.ok, name: item.name, detail: item.ok ? undefined : item.detail })) }, null, 2));
process.exitCode = failed.length ? 1 : 0;

View File

@@ -0,0 +1,176 @@
#!/usr/bin/env node
// Build a project's assembly through the real UI.
//
// Everything a learner can click goes through the UI: create the assembly,
// load each part document, insert it at a position and rotation, accept. Joints
// and the solve still go through the workbench forms, in the order proven in
// tools/line-manual/ui-assemble.mjs.
//
// Input: the project's assembly replay, which records every insertion as
// {sourceDocument, sourceObject, position, rotation}. Nothing is invented: the
// same replay the videos are cut from supplies the placement numbers.
//
// Usage: node assemble.mjs --project <dir> [--headed] [--dry]
import fs from "node:fs";
import path from "node:path";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import { loadProject, projectFromArgv, readJson, replayPath } from "./manifest.mjs";
import { createAssembly, createJoints, executeCommand, insertAll, insertedLinkCount, saveAssemblyBundle, solveAssembly, writeAssemblyReport, seedSources } from "./lib/assembly.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
const require = createRequire(path.join(webRoot, "package.json"));
const { chromium } = require("playwright");
const projectDir = projectFromArgv();
const project = loadProject(projectDir, { requireAssembly: true });
const args = process.argv.slice(2);
const headed = args.includes("--headed");
const dry = args.includes("--dry");
// The assembly replay lives beside the part replays and is identified by the
// assembly document name, so a project needs no extra path setting.
const replayFile = replayPath(project, project.assembly.document, { assembly: true });
if (!fs.existsSync(replayFile)) throw new Error(`no assembly replay at ${replayFile}`);
const replay = JSON.parse(fs.readFileSync(replayFile, "utf8"));
const inserts = replay.steps.filter(step => step.insert).map(step => step.insert);
if (!inserts.length) throw new Error(`assembly replay has no insertions: ${replayFile}`);
const rotated = inserts.filter(item => (item.rotation ?? [0, 0, 0, 1]).some((value, index) => index < 3 && value !== 0));
const groundDocument = project.assembly.groundDocument ?? inserts[0]?.sourceDocument;
if (dry) {
console.log(JSON.stringify({
project: project.name, document: project.assembly.document,
inserts: inserts.length, rotated: rotated.length, ground: groundDocument,
sourceDocuments: [...new Set(inserts.map(item => item.sourceDocument))].length,
}, null, 2));
process.exit(0);
}
const browser = await chromium.launch({
executablePath: "/usr/bin/google-chrome", headless: !headed,
args: ["--no-sandbox", "--disable-dev-shm-usage", "--enable-unsafe-swiftshader", "--use-gl=angle", "--use-angle=swiftshader"],
});
const page = await browser.newPage({ viewport: { width: 1600, height: 900 } });
const errors = [];
page.on("pageerror", error => errors.push(String(error).slice(0, 300)));
page.on("console", message => { if (message.type() === "error") errors.push(message.text().slice(0, 300)); });
const started = Date.now();
let done = [];
let fatal = null;
let joints = [];
let solves = [];
// Joints and the solve are optional replay content: a project that only inserts
// links keeps the old report shape, and one that records joints gets them run
// in replay order after the insertion session is committed.
const jointSteps = replay.steps.filter(step => typeof step.action === "string" && step.action.startsWith("Assembly_CreateJoint"));
const solveSteps = replay.steps.filter(step => step.action === "Assembly_SolveAssembly");
// Saving is opt-in per project (`assembly.saveBundle`): it opens the BOM task
// and clicks its own "Save FCStd" button, which stores to OPFS only.
const bomSteps = project.assembly.saveBundle
? replay.steps.filter(step => step.action === "Assembly_CreateBom") : [];
let saved = null;
try {
// The Insert Link task only sees documents in the browser's OPFS, so the
// sample FCStd files have to be staged there before any source can be loaded.
if (!project.paths.sampleDir) throw new Error("project.json needs paths.sampleDir for UI-driven assembly");
const sources = [];
for (const document of [...new Set(inserts.map(item => item.sourceDocument))]) {
const file = path.join(project.paths.sampleDir, `${document}.FCStd`);
if (!fs.existsSync(file)) throw new Error(`missing source document ${file}`);
sources.push({ name: `${document}.FCStd`, base64: fs.readFileSync(file).toString("base64") });
}
await page.goto(`${project.appOrigin}/`, { waitUntil: "domcontentloaded", timeout: 180000 });
await seedSources(page, sources);
await createAssembly(page, {
appOrigin: project.appOrigin,
pagePath: project.pages.assembly,
document: project.assembly.document,
label: project.assembly.label ?? project.assembly.document,
});
done = await insertAll(page, inserts, { groundDocument });
const reported = await insertedLinkCount(page);
// Every insert must be reflected in the task's own list before we call it good.
if (reported && reported !== done.length) {
throw new Error(`task lists ${reported} links but ${done.length} were inserted`);
}
if (jointSteps.length) {
joints = await createJoints(page, jointSteps);
if (joints.length !== jointSteps.length) {
throw new Error(`${joints.length} joints created, replay records ${jointSteps.length}`);
}
}
for (const step of solveSteps) solves.push(await solveAssembly(page, step));
if (bomSteps.length) {
// The BOM command opens the task panel; its own Save FCStd button then
// writes the bundle to OPFS (documents + manifest), never to disk.
for (const step of bomSteps) await executeCommand(page, step.action, step.args);
saved = await saveAssemblyBundle(page, { document: project.assembly.document });
}
} catch (error) {
fatal = String(error).slice(0, 800);
} finally {
await browser.close();
}
// Compare what the UI did against the replay, value by value: an insert that
// silently dropped its rotation would still "succeed" and only show up as a
// mis-assembled model much later.
const mismatches = [];
for (const [index, expected] of inserts.entries()) {
const actual = done[index];
if (!actual) { mismatches.push(`${expected.sourceDocument}: not inserted`); continue; }
if (actual.sourceDocument !== expected.sourceDocument) mismatches.push(`#${index + 1} document ${actual.sourceDocument} != ${expected.sourceDocument}`);
const quaternion = actual.rotation ?? [0, 0, 0, 1];
const wanted = expected.rotation ?? [0, 0, 0, 1];
if (quaternion.some((value, at) => Math.abs(value - wanted[at]) > 1e-6))
mismatches.push(`${expected.sourceDocument}: rotation ${quaternion.join(",")} != ${wanted.join(",")}`);
const position = actual.position ?? [0, 0, 0];
const target = expected.position ?? [0, 0, 0];
if (position.some((value, at) => Math.abs(value - target[at]) > 1e-6))
mismatches.push(`${expected.sourceDocument}: position ${position.join(",")} != ${target.join(",")}`);
}
// A save that silently stored nothing is a persistence gap, not a detail.
// Only the manifest is asserted here: the document store already holds the
// staged source files, so its count says nothing about this save.
if (bomSteps.length && !saved?.manifestStored) {
mismatches.push(`OPFS 未存储装配清单 ${project.assembly.document}.assembly.json`);
}
const report = {
schema: "freecad-web-cad-ui-rebuild/assembly/v1",
generatedAt: new Date().toISOString(),
project: project.name,
document: project.assembly.document,
groundDocument,
expected: { inserts: inserts.length, rotated: rotated.length, joints: jointSteps.length, solves: solveSteps.length },
inserted: done.length,
joints,
solves: solves.map(solve => ({
label: solve.label, components: solve.components.length,
malformed: solve.components.filter(component => !Array.isArray(component.position) || component.position.length !== 3
|| !component.position.every(Number.isFinite)
|| !Array.isArray(component.rotation) || component.rotation.length !== 4
|| !component.rotation.every(Number.isFinite)).length,
diagnostics: solve.diagnostics,
})),
components: solves.at(-1)?.components ?? [],
saved,
rotated: done.filter(item => (item.rotation ?? [0, 0, 0, 1]).some((value, index) => index < 3 && value !== 0)).length,
mismatches,
seconds: (Date.now() - started) / 1000,
fatal,
pageErrors: errors.slice(-10),
links: done,
};
const file = writeAssemblyReport(project.paths.runDir, project.assembly.document, report);
console.log(JSON.stringify({
document: project.assembly.document, inserted: report.inserted, rotated: report.rotated,
expected: report.expected, mismatches: mismatches.length, fatal,
seconds: Math.round(report.seconds), report: file,
}));
process.exitCode = fatal || mismatches.length ? 1 : 0;

View File

@@ -0,0 +1,129 @@
#!/usr/bin/env node
// Generate the per-step UI operation list for every part in a project.
//
// Reads each part's replay (the scripted build) plus one snapshot of the
// finished FCStd to recover the sketch coordinates the replay compacted away.
// Output: <outDir>/ui-steps/<document>.json and index.json
//
// Usage: node build-steps.mjs --project <dir> [partId ...]
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { loadProject, projectFromArgv, readJson, replayPath } from "./manifest.mjs";
import { uiStepsFor } from "./lib/steps.mjs";
import { readReplay } from "./lib/replay.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
const repoRoot = path.resolve(webRoot, "..");
const projectDir = projectFromArgv();
const project = loadProject(projectDir, { requireParts: true });
const projectArg = process.argv.slice(2)[process.argv.slice(2).indexOf("--project") + 1];
const wanted = process.argv.slice(2).filter(value => !value.startsWith("--") && value !== projectArg
&& process.argv.slice(2)[process.argv.indexOf(value) - 1] !== "--project");
const { loadWasmProbe } = await import(path.join(repoRoot, "tools", "wasm-probe-runtime.mjs"));
fs.mkdirSync(project.paths.stepsDir, { recursive: true });
const results = [];
const failures = [];
const selected = wanted.length
? project.parts.filter(part => wanted.includes(part.id) || wanted.includes(part.document))
: project.parts;
// One probe instance serves every part: the module import is cached but each
// loadWasmProbe() call instantiates a fresh kernel (and pthread workers), which
// is the leak behind long full-catalog runs.
let probe = null;
const kernelFor = async () => {
if (!probe) probe = await loadWasmProbe(path.join(webRoot, "public", "kernel"), "FreeCADWebPartDesignRuntimeProbe");
return probe.kernel;
};
for (const part of selected) {
const replayFile = replayPath(project, part.document);
const sampleFile = project.paths.sampleDir ? path.join(project.paths.sampleDir, `${part.document}.FCStd`) : null;
if (!fs.existsSync(replayFile)) { failures.push(`${part.document}: missing replay ${replayFile}`); continue; }
if (!sampleFile || !fs.existsSync(sampleFile)) { failures.push(`${part.document}: missing sample FCStd`); continue; }
const replay = readReplay(replayFile);
const kernel = await kernelFor();
const send = (action, args = {}) => JSON.parse(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify({
cmd: "partdesign.document",
args: { schema: "freecad-web-partdesign-document/v1", module: "PartDesign",
document: part.document, action, includeMesh: false, ...args },
})]));
let snapshot;
try {
// The probe's open action restores from a path inside the WASM filesystem;
// it does not decode a `bytes` argument. The FCStd has to be written into
// Emscripten's /tmp first, exactly as the browser build does.
const stagedPath = `/tmp/${part.document}.FCStd`;
kernel.FS.writeFile(stagedPath, fs.readFileSync(sampleFile));
const opened = send("open", { path: stagedPath });
if (!opened.ok) throw new Error(`open failed: ${String(opened.error).slice(0, 200)}`);
const snap = send("snapshot");
if (!snap.ok) throw new Error(`snapshot failed: ${String(snap.error).slice(0, 200)}`);
snapshot = snap.result?.objects ?? [];
} catch (error) {
failures.push(`${part.document}: ${error.message}`);
send("close");
continue;
}
const { steps, failures: local } = uiStepsFor(part.document, replay, snapshot, {
pages: project.pages, featureCommands: project.featureCommands,
});
failures.push(...local);
if (steps.length !== replay.steps.length) {
failures.push(`${part.document}: ${steps.length} ui steps but the replay has ${replay.steps.length}`);
}
const record = {
schema: "freecad-web-cad-ui-rebuild/ui-steps/v1",
generatedAt: new Date().toISOString(),
project: project.name,
document: part.document,
episode: part.id,
title: part.title,
steps,
};
fs.writeFileSync(path.join(project.paths.stepsDir, `${part.document}.json`), `${JSON.stringify(record, null, 2)}\n`);
results.push({ id: part.id, document: part.document, steps: steps.length });
send("close");
}
// A subset run must not drop the other parts from the index: regenerate the
// entries it touched and keep whatever an earlier full run recorded.
const indexFile = path.join(project.paths.stepsDir, "index.json");
const previous = [];
if (wanted.length && fs.existsSync(indexFile)) {
try {
previous.push(...(JSON.parse(fs.readFileSync(indexFile, "utf8")).documents ?? []));
} catch {
// A corrupt index is rebuilt from this run only.
}
}
const merged = new Map(previous.map(item => [item.document, item]));
for (const item of results) merged.set(item.document, item);
const index = {
schema: "freecad-web-cad-ui-rebuild/ui-steps-index/v1",
generatedAt: new Date().toISOString(),
project: project.name,
documents: [...merged.values()],
failures,
};
fs.writeFileSync(indexFile, `${JSON.stringify(index, null, 2)}\n`);
// Write to fd 1 synchronously: process.exit() below would otherwise race the
// async pipe write. The probe's pthread worker keeps the event loop alive, so
// a finished run has to exit explicitly or it looks hung after the summary.
fs.writeFileSync(1, `${JSON.stringify({
documents: results.length,
steps: results.reduce((sum, item) => sum + item.steps, 0),
failures,
}, null, 2)}\n`);
process.exit(failures.length ? 1 : 0);

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env node
// Pre-flight: prove the current display can actually be captured before a
// recording lane starts.
//
// Four episodes were recorded on a display whose GL surface x11grab could not
// see, and produced perfectly valid pure-black videos that passed every
// structural check in verify.mjs. This check exists so that failure is caught
// in 10 seconds instead of after a 4-minute recording.
//
// Usage: node check-capture.mjs [--display :1]
import { spawnSync } from "node:child_process";
import fs from "node:fs";
const args = process.argv.slice(2);
const index = args.indexOf("--display");
const display = index >= 0 ? args[index + 1] : (process.env.COURSE_VIDEO_DISPLAY ?? ":1");
const out = "/tmp/freecad-capture-probe.png";
fs.rmSync(out, { force: true });
const grab = spawnSync("ffmpeg", ["-y", "-f", "x11grab", "-video_size", "1600x900",
"-i", `${display}.0+0,0`, "-frames:v", "1", out, "-loglevel", "error"], { encoding: "utf8" });
if (!fs.existsSync(out)) {
console.log(JSON.stringify({ ok: false, display, error: "capture produced no frame", stderr: grab.stderr?.slice(0, 200) }));
process.exit(1);
}
const bytes = spawnSync("ffmpeg", ["-y", "-i", out, "-f", "rawvideo", "-pix_fmt", "gray", "-loglevel", "error", "-"],
{ maxBuffer: 64 << 20 }).stdout ?? Buffer.alloc(0);
let sum = 0;
let max = 0;
for (const value of bytes) { sum += value; if (value > max) max = value; }
const mean = bytes.length ? sum / bytes.length : 0;
// A live desktop contains thousands of colours across the whole frame. `max`
// alone is a false positive: while the display is asleep a stray cursor pixel
// can still be 255 while the rest of the frame is pure black, which is exactly
// how the first re-record attempt passed its own preflight and produced four
// more black episodes. Require real brightness AND real colour spread.
const distinct = new Set();
const rgb = spawnSync("ffmpeg", ["-y", "-i", out, "-f", "rawvideo", "-pix_fmt", "rgb24", "-loglevel", "error", "-"],
{ maxBuffer: 128 << 20 }).stdout ?? Buffer.alloc(0);
for (let index = 0; index + 2 < rgb.length; index += 3 * 997) distinct.add((rgb[index] << 16) | (rgb[index + 1] << 8) | rgb[index + 2]);
const awake = mean > 3 && max > 24 && distinct.size > 20;
console.log(JSON.stringify({ ok: awake, display, mean: Number(mean.toFixed(1)), max,
distinctColors: distinct.size, bytes: bytes.length }));
process.exitCode = awake ? 0 : 1;

View File

@@ -0,0 +1,172 @@
#!/usr/bin/env node
// Capture the geometry a process trace needs in order to be replayed.
//
// A trace records WHAT happened (action, arguments, seconds, the object list
// after each step) but carries no shapes: `snapshot` is null on every event and
// the heavy geometry lists are compacted to {count, sha256}. The shapes do not
// have to be re-simulated to get them back, though. Every PartDesign feature
// keeps the *accumulated* result of the body up to and including itself, so one
// `includeMesh` snapshot of the finished document already contains the shape of
// the model after every step.
//
// This is the generic form of the reducer case's original script: the three
// directories (traces, FCStd samples, replay output) and the source label are
// arguments, so any process case can produce the same replay records.
//
// Output: <out-dir>/<document>.json, one record per trace step:
// { step, label, action, seconds, args, feature, volume, faceCount,
// mesh: { positions, normals, triangleCount, bounds } }
// `feature` is the object the step created, derived from the trace itself (the
// one new solid in `tips.objects` that was not there on the previous step), so
// nothing is guessed from naming conventions.
//
// Usage:
// node web/tools/cad-ui-rebuild/capture-replay.mjs \
// --trace-dir <case>/out/traces \
// --sample-dir <case>/out/FCStd \
// --out-dir <case>/out/replay \
// [--source-prefix web/teaching/cases/<case>/out/FCStd] \
// [--only P01,CarrierDeck] [--assembly CarrierAssembly]
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const here = path.dirname(fileURLToPath(import.meta.url));
export const webRoot = path.resolve(here, "..", "..");
export const repoRoot = path.resolve(webRoot, "..");
const SCHEMA = "freecad-web-process-replay/v1";
// Datum scaffolding is created with the body and is never a modelling step.
const notAFeature = type => /^(App::(Origin|Line|Plane|Point)|PartDesign::Body)$/.test(type ?? "");
/** Keep 1 µm of positional resolution; that is far below any teaching need. */
const q3 = value => Math.round(value * 1000) / 1000;
function trim(raw) {
if (!raw?.positions?.length) return null;
return {
positions: Array.prototype.map.call(raw.positions, q3),
normals: raw.normals?.length ? Array.prototype.map.call(raw.normals, v => Math.round(v * 1000) / 1000) : [],
triangleCount: raw.triangleCount ?? raw.positions.length / 9,
bounds: raw.bounds ?? null,
};
}
function parseArgs(argv) {
const args = { only: [], assembly: [] };
for (let index = 0; index < argv.length; index += 1) {
const key = argv[index];
const value = argv[index + 1];
if (!key.startsWith("--")) continue;
index += 1;
if (key === "--trace-dir") args.traceDir = value;
else if (key === "--sample-dir") args.sampleDir = value;
else if (key === "--out-dir") args.outDir = value;
else if (key === "--source-prefix") args.sourcePrefix = value;
else if (key === "--only") args.only.push(...value.split(",").filter(Boolean));
else if (key === "--assembly") args.assembly.push(...value.split(",").filter(Boolean));
else throw new Error(`unknown argument ${key}`);
}
for (const key of ["traceDir", "sampleDir", "outDir"]) {
if (!args[key]) throw new Error(`--${key.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`)} is required`);
}
return args;
}
/**
* Snapshot one finished document and turn its trace into replay steps.
* The caller owns the kernel lifecycle (see loadWasmProbe usage below).
*/
export function makeCapture({ kernel, sampleDir, sourcePrefix }) {
const dispatch = (document, action, extra = {}) => JSON.parse(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify({
cmd: "partdesign.document",
args: { schema: "freecad-web-partdesign-document/v1", module: "PartDesign", document, action, includeMesh: false, ...extra },
})]));
return async function capture(document, trace) {
const file = path.join(sampleDir, `${document}.FCStd`);
if (!fs.existsSync(file)) throw new Error(`missing sample document ${file}`);
kernel.FS.writeFile(`/tmp/${document}.FCStd`, fs.readFileSync(file));
const opened = dispatch(document, "open", { path: `/tmp/${document}.FCStd` });
if (!opened.ok) throw new Error(`${document} open failed: ${String(opened.error).slice(0, 200)}`);
try {
const started = Date.now();
const snap = dispatch(document, "snapshot", { includeMesh: true });
if (!snap.ok) throw new Error(`${document} snapshot failed: ${String(snap.error).slice(0, 200)}`);
const meshMs = Date.now() - started;
const byName = new Map((snap.result?.objects ?? []).map(object => [object.name, object]));
const steps = [];
let previous = new Set();
for (const event of trace.events) {
const names = (event.tips?.objects ?? []).map(object => object.name);
const created = names.filter(name => !previous.has(name));
// A step may remove objects too (a pocket consumes its profile as the new
// tip); the shape that matters is the newest solid in the body.
const solid = created.map(name => byName.get(name)).filter(object => object && !notAFeature(object?.type)).at(-1) ?? null;
previous = new Set(names);
steps.push({
step: event.step, label: event.label, action: event.action,
seconds: event.seconds, args: event.args,
feature: solid?.name ?? null,
volume: solid?.volume ?? null,
faceCount: solid?.faceCount ?? null,
mesh: trim(solid?.mesh),
});
}
return {
schema: SCHEMA, document,
source: sourcePrefix ? `${sourcePrefix.replace(/\/$/, "")}/${document}.FCStd` : file,
meshMs, steps,
};
} finally {
try { dispatch(document, "close"); } catch { /* document may already be closed */ }
}
};
}
/** Run the whole capture over a directory of traces; returns the exit code. */
export async function runCapture(args) {
const { loadWasmProbe } = await import(path.join(repoRoot, "tools", "wasm-probe-runtime.mjs"));
const { kernel } = await loadWasmProbe(path.join(webRoot, "public", "kernel"), "FreeCADWebPartDesignRuntimeProbe");
const capture = makeCapture({ kernel, sampleDir: args.sampleDir, sourcePrefix: args.sourcePrefix });
const traces = fs.readdirSync(args.traceDir).filter(name => name.endsWith(".json")).sort();
const results = [];
const failures = [];
fs.mkdirSync(args.outDir, { recursive: true });
for (const name of traces) {
const document = name.replace(/\.json$/, "");
if (args.only.length && !args.only.includes(document)) continue;
const trace = JSON.parse(fs.readFileSync(path.join(args.traceDir, name), "utf8"));
// Assembly traces are a different kind of record: their steps insert whole
// documents, so their geometry comes from the part replays instead.
if (args.assembly.includes(document)) {
results.push({ document, kind: "assembly", events: trace.events.length, steps: 0, bytes: 0 });
continue;
}
try {
const replay = await capture(document, trace);
const json = JSON.stringify(replay);
fs.writeFileSync(path.join(args.outDir, `${document}.json`), json);
const withMesh = replay.steps.filter(step => step.mesh).length;
const solids = replay.steps.filter(step => step.feature).length;
results.push({ document, kind: "part", events: trace.events.length, steps: replay.steps.length, withMesh, solids,
bytes: json.length, meshMs: replay.meshMs });
if (!withMesh) failures.push(`${document}: no step produced a mesh`);
} catch (error) {
failures.push(`${document}: ${error instanceof Error ? error.message : String(error)}`);
}
}
kernel.PThread?.terminateAllThreads?.();
fs.writeFileSync(path.join(args.outDir, "index.json"), `${JSON.stringify({
schema: SCHEMA, generatedAt: new Date().toISOString(), documents: results, failures,
}, null, 2)}\n`);
console.log(JSON.stringify({ results, failures }, null, 2));
return failures.length ? 1 : 0;
}
async function main() {
process.exitCode = await runCapture(parseArgs(process.argv.slice(2)));
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();

View File

@@ -0,0 +1,179 @@
#!/usr/bin/env node
// Drive the real Web FreeCAD UI to rebuild one part, capturing a screenshot per step.
//
// Usage: node drive.mjs --project <dir> <partId|document> [--headed] [--slow]
// Evidence: <outDir>/ui-run/<document>.json
// <stillsDir>/<partId>/<scene>.png
import fs from "node:fs";
import path from "node:path";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import { loadProject, projectFromArgv, readJson, replayPath } from "./manifest.mjs";
import { PAGE, waitForWorkspace, newDocumentWithBody, runStep, tipVolume, selectTip } from "./lib/driver.mjs";
import { readReplay } from "./lib/replay.mjs";
import { stillName } from "./lib/stills.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
const require = createRequire(path.join(webRoot, "package.json"));
const { chromium } = require("playwright");
const projectDir = projectFromArgv();
const project = loadProject(projectDir, { requireParts: true });
const args = process.argv.slice(2);
// Skip the value that belongs to --project; it may be a directory or a manifest
// file, and either way it is not a part id.
const projectArg = args[args.indexOf("--project") + 1];
const key = args.find(value => !value.startsWith("--") && value !== projectArg
&& args[args.indexOf(value) - 1] !== "--project");
if (!key) throw new Error("usage: drive.mjs --project <dir> <partId> [--headed] [--slow]");
const part = project.parts.find(item => item.id === key || item.document === key);
if (!part) throw new Error(`project ${project.name} has no part "${key}"`);
const headed = args.includes("--headed");
const slow = args.includes("--slow") ? 350 : 0;
const stepsFile = path.join(project.paths.stepsDir, `${part.document}.json`);
if (!fs.existsSync(stepsFile)) {
throw new Error(`no ui-steps for ${part.document}; run build-steps.mjs --project ${projectDir} first`);
}
const uiSteps = JSON.parse(fs.readFileSync(stepsFile, "utf8"));
const replayFile = replayPath(project, part.document);
if (!fs.existsSync(replayFile)) throw new Error(`no replay for ${part.document} in ${project.paths.replayDir}`);
const replay = readReplay(replayFile);
const stillsDir = path.join(project.paths.stillsDir, part.id);
fs.mkdirSync(stillsDir, { recursive: true });
fs.mkdirSync(project.paths.runDir, { recursive: true });
/**
* Internal names of every tree row: the workspace's own object names.
*
* The tree pane sizes its viewport to the full row list (`document-tree.tsx`),
* so every row stays mounted and a single read sees them all.
*/
async function internalNames(page) {
const visible = await page.locator('[role="treeitem"] .fc-tree-col-internal').allTextContents();
return [...new Set(visible.map(name => name.trim()).filter(Boolean))];
}
/**
* Wait for the workspace to finish a native transaction and publish it.
*
* `edit()` in the workspace renders "计算中..." while the kernel request is in
* flight and only swaps `documents[document]` afterwards, so a heavy feature
* (a chamfer over 180 deck edges takes tens of seconds) has no tree row yet
* when the click handler returns. Poll until the row count exceeds `minimum`
* and the busy status has cleared.
*/
async function waitForRows(page, minimum, timeout = 240000) {
const deadline = Date.now() + timeout;
let count = 0;
const busy = () => page.evaluate(() => [...document.querySelectorAll('[role="status"]')]
.some(node => (node.textContent ?? "").includes("计算中")));
while (Date.now() < deadline) {
count = await page.locator('[role="treeitem"]').count();
if (count >= minimum && !(await busy())) return count;
await page.waitForTimeout(250);
}
throw new Error(`model tree stayed at ${count} rows (wanted >= ${minimum}) for ${timeout} ms`);
}
const browser = await chromium.launch({
executablePath: "/usr/bin/google-chrome", headless: !headed,
args: ["--no-sandbox", "--disable-dev-shm-usage", "--enable-unsafe-swiftshader", "--use-gl=angle", "--use-angle=swiftshader"],
});
const page = await browser.newPage({ viewport: { width: 1600, height: 900 } });
const errors = [];
page.on("pageerror", error => errors.push(String(error).slice(0, 300)));
page.on("console", message => { if (message.type() === "error") errors.push(message.text().slice(0, 300)); });
const results = [];
const uiNames = new Map();
const started = Date.now();
try {
await page.goto(`${project.appOrigin}/${PAGE}`, { waitUntil: "domcontentloaded", timeout: 180000 });
await waitForWorkspace(page);
await newDocumentWithBody(page);
for (const [index, step] of uiSteps.steps.entries()) {
const name = stillName(project, part, index, uiSteps.steps);
const t0 = Date.now();
let status = "ok";
try {
// The workspace names objects itself (Sketch1, Pad1 …), so a later step's
// profile/sections/base/originals must be translated to the UI's name.
const resolved = { ...step };
// Every reference must resolve. A name that no earlier step recorded means
// the plan is wrong; failing here beats letting the driver pick a default.
const renamed = name => {
if (uiNames.has(name)) return uiNames.get(name);
throw new Error(`no UI object recorded for ${name}`);
};
if (resolved.profile) resolved.profile = renamed(resolved.profile);
if (resolved.base) resolved.base = renamed(resolved.base);
if (Array.isArray(resolved.sections) && resolved.sections.length) {
resolved.sections = resolved.sections.map(section => (typeof section === "string" ? renamed(section) : section));
}
if (Array.isArray(resolved.originals) && resolved.originals.length) {
resolved.originals = resolved.originals.map(renamed);
}
const before = new Set(await internalNames(page));
const rowsBefore = await page.locator('[role="treeitem"]').count();
await runStep(page, resolved);
await waitForRows(page, rowsBefore + 1);
// The workspace names objects itself (Sketch1, Pad7, Chamfer1 …). The new
// row's internal name is the object name the reference selects expect, and
// later steps address this object by the kernel's name, so record the pair.
const created = (await internalNames(page)).filter(name => !before.has(name));
if (created.length !== 1) throw new Error(`expected one new object, saw [${created.join(", ")}]`);
uiNames.set(step.object, created[0]);
} catch (error) {
status = `fail: ${error instanceof Error ? error.message.slice(0, 240) : String(error)}`;
}
if (slow) await page.waitForTimeout(slow);
await page.screenshot({ path: path.join(stillsDir, `${name}.png`) });
await selectTip(page);
const volume = await tipVolume(page);
const expectedVolume = replay.steps[index]?.volume ?? null;
const match = volume != null && expectedVolume
? Math.abs(volume - expectedVolume) / Math.abs(expectedVolume) < 1e-6 : null;
results.push({ step: step.step, label: step.label, kind: step.kind, command: step.command,
uiName: step.kind === "sketch" ? uiNames.get(step.object) ?? null : null,
volume, expectedVolume, volumeMatches: match, status, ms: Date.now() - t0 });
if (status !== "ok") break;
}
await selectTip(page);
const volume = await tipVolume(page);
const expected = replay.steps.at(-1)?.volume ?? null;
const relative = volume != null && expected ? Math.abs(volume - expected) / Math.abs(expected) : null;
const report = {
schema: "freecad-web-cad-ui-rebuild/ui-run/v1",
generatedAt: new Date().toISOString(),
project: project.name,
episode: part.id, document: part.document,
steps: results.length, stepsTotal: uiSteps.steps.length,
failed: results.filter(item => item.status !== "ok").length,
volume, expected, relativeError: relative,
volumeMatches: relative != null && relative < 1e-6,
seconds: (Date.now() - started) / 1000,
pageErrors: errors.slice(-10), results,
};
fs.writeFileSync(path.join(project.paths.runDir, `${part.document}.json`), `${JSON.stringify(report, null, 2)}\n`);
console.log(JSON.stringify({ episode: part.id, steps: report.steps, failed: report.failed,
volume, expected, relativeError: relative, volumeMatches: report.volumeMatches,
seconds: Math.round(report.seconds), pageErrors: report.pageErrors.length }));
process.exitCode = report.failed === 0 && report.steps === report.stepsTotal ? 0 : 1;
} catch (error) {
fs.writeFileSync(path.join(project.paths.runDir, `${part.document}.json`), `${JSON.stringify({
schema: "freecad-web-cad-ui-rebuild/ui-run/v1", project: project.name,
episode: part.id, document: part.document,
fatal: String(error).slice(0, 800), results, pageErrors: errors.slice(-10),
}, null, 2)}\n`);
console.error(JSON.stringify({ fatal: String(error).slice(0, 400), pageErrors: errors.slice(-5) }));
process.exitCode = 1;
} finally {
await browser.close();
}

View File

@@ -0,0 +1,278 @@
// Drive the assembly through the real UI.
//
// The part-building half of this tool is proven; assembly used to be built only
// through kernel probe calls because the insert-link task hardcoded the identity
// rotation. That is now a React control (`Insert link rotation W/X/Y/Z` plus
// presets), so creation + every insertion can go through the same surface a
// learner uses. Joints and solving still use the workbench parameter forms,
// following the order proven in tools/line-manual/ui-assemble.mjs.
//
// Ordering matters and is not obvious: the first inserted link becomes the
// grounded anchor, so the ground part must be inserted first, before anything
// else. `orderedInserts` enforces that.
import fs from "node:fs";
import path from "node:path";
/** Sort inserts so the ground part comes first, keeping the rest in authored order. */
export function orderedInserts(inserts, groundDocument) {
if (!groundDocument) return [...inserts];
const ground = inserts.filter(item => item.sourceDocument === groundDocument);
const rest = inserts.filter(item => item.sourceDocument !== groundDocument);
return [...ground, ...rest];
}
/** Wait for the assembly task surface to settle after an action. */
const settle = (page, ms = 700) => page.waitForTimeout(ms);
/**
* Copy the project's sample FCStd files into the browser's OPFS document
* directory, which is where the Insert Link task lists sources from
* (`listDocumentFiles()` in src/storage.ts reads `freecad-documents`, not
* `freecad-exports`; exports hold STEP/STL/etc, not editable documents).
*
* The web app never reads the host filesystem, so a UI-driven assembly needs the
* documents present in OPFS first. Documents are addressed by bare filename.
*/
export async function seedSources(page, files) {
await page.evaluate(async (entries) => {
const root = await navigator.storage.getDirectory();
const dir = await root.getDirectoryHandle("freecad-documents", { create: true });
for (const entry of entries) {
const handle = await dir.getFileHandle(entry.name, { create: true });
const writable = await handle.createWritable();
const binary = atob(entry.base64);
const bytes = new Uint8Array(binary.length);
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
await writable.write(bytes);
await writable.close();
}
}, files);
return files.map(entry => entry.name);
}
/**
* Open the assembly page and create the assembly document.
* Desktop equivalent: Assembly workbench → Create Assembly.
*/
export async function createAssembly(page, { appOrigin, pagePath, document, label }) {
await page.goto(`${appOrigin}/${pagePath}`, { waitUntil: "domcontentloaded", timeout: 180000 });
const create = page.locator('section[aria-label="Create assembly"]');
await create.waitFor({ timeout: 180000 });
await page.locator('input[aria-label="Assembly document name"]').first().fill(document);
if (label) await page.locator('input[aria-label="Assembly label"]').first().fill(label);
await create.getByRole("button", { name: "Create" }).first().click();
await settle(page, 3000);
}
/**
* Open the Insert Link task and load one source file from OPFS.
* The task loads one file per action; the kernel probe can batch, the UI cannot.
*/
export async function loadSource(page, fileName) {
const task = page.locator('section[aria-label="Insert assembly link"]');
await task.waitFor({ timeout: 120000 });
const select = page.locator('select[aria-label="Insert link source file"]');
await select.selectOption(fileName);
await settle(page, 300);
await task.getByRole("button", { name: "Load source", exact: true }).click();
// Loading parses the FCStd; a large document takes a few seconds. The
// "Insert" button is already visible before any load, so it is not a load
// signal. Wait for the candidate list itself to fill, and for the status
// line to name the file that was just loaded -- with several documents open
// the options from the previous load are still present until this one lands.
await page.waitForFunction(name => {
const status = document.querySelector('section[aria-label="Insert assembly link"] p[role="status"]');
const objects = document.querySelector('select[aria-label="Insert link source object"]');
return Boolean(status) && status.textContent.includes(`Loaded ${name}`)
&& Boolean(objects) && objects.options.length > 1;
}, fileName, { timeout: 180000 });
await settle(page, 600);
}
/**
* Insert the loaded document's object at a position and rotation.
*
* The rotation fields are the React control that replaced the hardcoded
* identity quaternion; passing [0,0,0,1] reproduces the old behaviour exactly.
*/
export async function insertLink(page, { sourceDocument, sourceObject, position, rotation, rigid = true }) {
const task = page.locator('section[aria-label="Insert assembly link"]');
const objectSelect = page.locator('select[aria-label="Insert link source object"]');
// Option values are `documentId:object`. Parts share object names across
// documents (`Body` exists in every reducer part), so the bare object name
// cannot be used as the value -- the task would always resolve to whichever
// document was opened first.
const key = `${sourceDocument}:${sourceObject}`;
const values = await objectSelect.evaluate(node => [...node.options].map(option => option.value));
if (!values.includes(key)) throw new Error(`source object ${key} not among ${values.join(", ")}`);
await objectSelect.selectOption(key);
for (const [index, axis] of ["X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="Insert link position ${axis}"]`).first();
await input.fill(String(position?.[index] ?? 0));
await input.press("Enter");
}
const quaternion = rotation ?? [0, 0, 0, 1];
for (const [index, axis] of ["W", "X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="Insert link rotation ${axis}"]`).first();
await input.fill(String(quaternion[index]));
await input.press("Enter");
}
const rigidBox = task.locator('input[type="checkbox"]').first();
if (await rigidBox.count()) await rigidBox.setChecked(rigid).catch(() => {});
await task.getByRole("button", { name: "Insert", exact: true }).click();
await settle(page, 400);
}
/** Commit the insertion session. */
export async function acceptLinks(page) {
const task = page.locator('section[aria-label="Insert assembly link"]');
await task.getByRole("button", { name: "Accept", exact: true }).click();
await settle(page, 2000);
}
/**
* Insert every link in the planned order, loading each source document once.
* Returns per-insert evidence so the caller can assert rotation was preserved.
*/
export async function insertAll(page, inserts, { groundDocument, loadOne = loadSource } = {}) {
const ordered = orderedInserts(inserts, groundDocument);
const loaded = new Set();
const done = [];
for (const item of ordered) {
const fileName = `${item.sourceDocument}.FCStd`;
if (!loaded.has(fileName)) { await loadOne(page, fileName); loaded.add(fileName); }
await insertLink(page, item);
done.push({ sourceDocument: item.sourceDocument, sourceObject: item.sourceObject,
position: item.position, rotation: item.rotation ?? [0, 0, 0, 1] });
}
await acceptLinks(page);
return done;
}
/**
* How many links the task reports, read from the visible list.
* Used as a cheap post-condition before the expensive joint and solve steps.
*/
export async function insertedLinkCount(page) {
return page.evaluate(() => document.querySelectorAll('ul[aria-label="Inserted links"] li').length);
}
/**
* Run one workbench command through the generic parameter form.
*
* Joints and the solve have no bespoke React control of their own, so they go
* through the help-page panel the same way the E18 course episode does: click
* the command, put its payload in #payload-editor, run it, wait for the state
* response to change, and return the native result.
*/
export async function executeCommand(page, command, payload, timeout = 300000) {
const before = await page.evaluate(() => window.__freecadWorkbenchState?.response?.requestId ?? null);
await page.locator(`button[data-help-page="${command}"]`).first().click();
await page.locator("#payload-editor").fill(JSON.stringify(payload));
await page.getByRole("button", { name: "执行选中命令" }).click();
await page.waitForFunction(id => {
const response = window.__freecadWorkbenchState?.response;
return Boolean(response) && response.requestId !== id;
}, before, { timeout });
const response = await page.evaluate(() => window.__freecadWorkbenchState?.response);
if (response?.kind !== "result") {
throw new Error(`${command}: ${response?.error?.code} ${response?.error?.message}`);
}
return response.result?.records?.find(record => record.status === "exposed")?.result ?? response.result;
}
/** Component names follow insertion order: Component, Component001, … */
export function componentName(index) {
return index === 0 ? "Component" : `Component${String(index).padStart(3, "0")}`;
}
/**
* Create every joint the replay records, in order. Each step already carries a
* complete payload (selection + references), so nothing is re-derived here.
*/
export async function createJoints(page, steps) {
const done = [];
for (const step of steps) {
const native = await executeCommand(page, step.action, step.args);
done.push({
label: step.label,
type: native?.jointType ?? null,
joint: native?.joint ?? null,
message: native?.message ?? null,
});
}
return done;
}
/** Run the solve and summarise what the solver returned for every component. */
export async function solveAssembly(page, step) {
const native = await executeCommand(page, step.action, step.args);
const components = (native?.components ?? []).map(component => ({
object: component.object ?? component.name ?? null,
position: component.placement?.position ?? null,
rotation: component.placement?.rotation ?? null,
}));
return { label: step.label, components, diagnostics: native?.diagnostics ?? native?.messages ?? null };
}
/**
* Save the assembly through the BOM task's own "Save FCStd" button, then read
* back what OPFS actually holds.
*
* Saving is OPFS-only by design (no automatic download). The bundle writes its
* FCStd files through storage.writeDocumentFile (`freecad-documents`) and the
* manifest `<documentId>.assembly.json` through writeRawStep (`freecad-1-2`),
* so both stores are checked here.
*/
export async function saveAssemblyBundle(page, { document, timeout = 300000 }) {
const section = page.locator('section[aria-label="Bill of materials task"]');
await section.waitFor({ timeout: 120000 });
const save = section.getByRole("button", { name: "Save FCStd", exact: true }).first();
const accept = section.getByRole("button", { name: "Accept", exact: true }).first();
// Native `save` refuses while the BOM task still owns an open session
// ("Accept or cancel the task first", AssemblyInsertLink.h), and the button is
// disabled for exactly that state -- clicking it blindly just times out.
// Accepting commits the table (columns, settings) before the bundle is built,
// so the saved FCStd carries what the task was showing.
await page.waitForFunction(() => {
const task = document.querySelector('section[aria-label="Bill of materials task"]');
if (!task) return false;
const buttons = [...task.querySelectorAll("button")];
const button = name => buttons.find(node => node.textContent?.trim() === name);
return Boolean(button("Save FCStd") && !button("Save FCStd").disabled)
|| Boolean(button("Accept") && !button("Accept").disabled);
}, null, { timeout: 120000 });
if (await save.isDisabled()) await accept.click();
await save.click();
await page.waitForFunction(() => {
const status = document.querySelector('section[aria-label="Bill of materials task"] p[role="status"]');
return Boolean(status) && /OPFS|保存/.test(status.textContent);
}, null, { timeout });
return page.evaluate(async (documentId) => {
const root = await navigator.storage.getDirectory();
const list = async name => {
try {
const dir = await root.getDirectoryHandle(name, { create: false });
const names = [];
for await (const [entry] of dir.entries()) names.push(entry);
return names.sort();
} catch {
return [];
}
};
const documents = (await list("freecad-documents")).filter(name => name.endsWith(".FCStd"));
const steps = await list("freecad-1-2");
const manifest = `${documentId}.assembly.json`;
return { files: documents, manifest, manifestStored: steps.includes(manifest) };
}, document);
}
/** Persist the assembly report next to the run evidence. */
export function writeAssemblyReport(runDir, document, report) {
fs.mkdirSync(runDir, { recursive: true });
const file = path.join(runDir, `${document}-assembly.json`);
fs.writeFileSync(file, `${JSON.stringify(report, null, 2)}\n`);
return file;
}

View File

@@ -0,0 +1,581 @@
// Drive the real Web FreeCAD UI to rebuild one part, step by step.
//
// Target page is `partdesign.html` (the standalone PartDesign workspace): it is
// the only surface that renders the sketch editor AND the profile features.
// The embedded PartDesign panel on project.html has no sketch controls at all
// (they only appear when the Workbench select is set to Sketcher), so driving it
// would need a workbench round-trip for every sketch.
//
// This exists to PROVE the generated instructions are true: every step in
// out/ui-steps is performed through the same controls a learner would use, and
// the finished volume is compared against the replay's. If the UI cannot express
// a step this driver fails loudly rather than the manual describing an
// impossible operation.
export const PAGE = "partdesign.html";
export async function waitForWorkspace(page) {
await page.waitForSelector('[aria-label="Native PartDesign view"]', { timeout: 180000 });
await page.waitForTimeout(1200);
}
/** Start a fresh document and body, so each part is built in isolation. */
export async function newDocumentWithBody(page) {
await page.locator('button[aria-label="新建文档"]').first().click();
await page.waitForTimeout(1500);
await page.locator('button[aria-label="新建 Body"]').first().click();
await page.waitForTimeout(1500);
}
async function fillVector(page, label, values) {
for (const [index, axis] of ["X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="${label} ${axis}"]`).first();
await input.fill(String(values?.[index] ?? 0));
await input.press("Enter");
}
}
async function fillGeometryRow(page, index, geometry) {
const n = index + 1;
const typeSelect = page.locator(`select[aria-label="Geometry ${n} type"]`);
await typeSelect.selectOption(geometry.type);
await page.waitForTimeout(150);
if (geometry.type === "line") {
await fillVector(page, `Geometry ${n} start`, geometry.start);
await fillVector(page, `Geometry ${n} end`, geometry.end);
} else if (geometry.type === "circle" || geometry.type === "arc") {
await fillVector(page, `Geometry ${n} center`, geometry.center);
await page.locator(`input[aria-label="Geometry ${n} radius"]`).fill(String(geometry.radius));
if (geometry.type === "arc") {
await page.locator(`input[aria-label="Geometry ${n} startAngle"]`).fill(String(geometry.startAngle));
await page.locator(`input[aria-label="Geometry ${n} endAngle"]`).fill(String(geometry.endAngle));
}
} else if (geometry.type === "ellipse") {
await fillVector(page, `Geometry ${n} center`, geometry.center);
await page.locator(`input[aria-label="Geometry ${n} majorRadius"]`).fill(String(geometry.majorRadius));
await page.locator(`input[aria-label="Geometry ${n} minorRadius"]`).fill(String(geometry.minorRadius));
} else if (geometry.type === "point") {
await fillVector(page, `Geometry ${n} point`, geometry.point);
}
}
async function fillConstraintRow(page, index, constraint) {
const n = index + 1;
await page.locator(`select[aria-label="Constraint ${n} type"]`).selectOption(constraint.type);
await page.waitForTimeout(150);
for (const slot of ["first", "second", "third"]) {
if (constraint[slot] === undefined) continue;
const select = page.locator(`select[aria-label="Constraint ${n} ${slot}"]`).first();
if (await select.count()) await select.selectOption(String(constraint[slot]));
}
for (const slot of ["firstPos", "secondPos", "thirdPos"]) {
if (!constraint[slot]) continue;
const select = page.locator(`select[aria-label="Constraint ${n} ${slot}"]`).first();
if (await select.count()) await select.selectOption(constraint[slot]);
}
if (constraint.value !== undefined) {
const input = page.locator(`input[aria-label="Constraint ${n} value"]`).first();
if (await input.count()) await input.fill(String(constraint.value));
}
}
/**
* Create a sketch from a geometry+constraint list.
*
* The editor opens with a four-line rectangle preset, so the row count has to be
* driven to the target shape: delete the surplus rows, then append and fill.
*/
export async function createSketch(page, step) {
const group = page.locator('[role="group"][aria-label="Profile type"]').first();
const label = step.profileType === "Circle" ? "圆形" : "几何与约束";
await group.getByRole("button", { name: label }).first().click();
await page.waitForTimeout(400);
if (step.profileType === "Circle") {
const radius = step.geometries?.[0]?.radius ?? step.parameters?.Radius;
if (radius !== undefined) await page.locator('input[aria-label="Sketch Radius"]').first().fill(String(radius));
} else {
const countGeometryRows = () => page.locator('select[aria-label^="Geometry "][aria-label$=" type"]').count();
let rows = await countGeometryRows();
while (rows > step.geometries.length) {
await page.locator(`button[aria-label="Remove geometry ${rows}"]`).first().click();
await page.waitForTimeout(100);
rows = await countGeometryRows();
}
while (rows < step.geometries.length) {
await page.locator('button[aria-label="Add sketch geometry"]').first().click();
await page.waitForTimeout(100);
rows = await countGeometryRows();
}
for (const [index, geometry] of step.geometries.entries()) await fillGeometryRow(page, index, geometry);
const countConstraintRows = () => page.locator('select[aria-label^="Constraint "][aria-label$=" type"]').count();
let constraints = await countConstraintRows();
while (constraints > step.constraints.length) {
await page.locator(`button[aria-label="Remove constraint ${constraints}"]`).first().click();
await page.waitForTimeout(100);
constraints = await countConstraintRows();
}
while (constraints < step.constraints.length) {
await page.locator('button[aria-label="Add sketch constraint"]').first().click();
await page.waitForTimeout(100);
constraints = await countConstraintRows();
}
for (const [index, constraint] of step.constraints.entries()) await fillConstraintRow(page, index, constraint);
}
await fillVector(page, "Sketch", step.position ?? [0, 0, 0]);
// A sketch is not always parallel to XY. Pick the plane whose quaternion the
// kernel snapshot reported; the "Custom" branch types the raw quaternion when
// the support is not one of the three axis-aligned planes.
const plane = await page.locator('select[aria-label="Sketch plane"]').first();
if (await plane.count()) {
const rotation = step.placementRotation ?? [0, 0, 0, 1];
const identity = rotation[0] === 0 && rotation[1] === 0 && rotation[2] === 0;
if (identity) await plane.selectOption("XY");
else {
await plane.selectOption("Custom");
const axes = ["W", "X", "Y", "Z"];
for (const [index, axis] of axes.entries()) {
const input = page.locator(`input[aria-label="Sketch rotation ${axis}"]`).first();
if (await input.count()) { await input.fill(String(rotation[index])); await input.press("Enter"); }
}
}
await page.waitForTimeout(200);
}
await page.locator('button[data-create-sketch]').first().click();
await page.waitForTimeout(2200);
}
/** The workspace names objects itself (Sketch1, Pad1 ...), so map as we go. */
export async function lastProfileName(page) {
await page.locator('[role="group"][aria-label="Profile feature"] button[data-feature-type="Pad"]').first().click().catch(() => {});
await page.waitForTimeout(250);
const values = await page.evaluate(() => {
const select = document.querySelector('select[aria-label="Feature Profile"]');
return select ? [...select.options].map(option => option.value).filter(Boolean) : [];
});
return values.at(-1) ?? null;
}
/** Select several options by value and notify React, as the panel does. */
async function selectMulti(page, locator, values) {
const picked = await locator.evaluate((node, wanted) => {
const found = [...node.options].filter(option => wanted.includes(option.value)).map(option => option.value);
if (!found.length) return [];
for (const option of node.options) option.selected = found.includes(option.value);
node.dispatchEvent(new Event("change", { bubbles: true }));
return found;
}, values);
await page.waitForTimeout(300);
return picked;
}
/** Open a collapsed `<details>` task group by the words in its summary. */
async function openDesignGroup(page, pattern) {
await page.evaluate(source => {
const wanted = new RegExp(source, "i");
for (const details of document.querySelectorAll("details.design-task-group")) {
const summary = details.querySelector("summary");
if (summary && wanted.test(summary.textContent ?? "")) details.open = true;
}
}, pattern);
await page.waitForTimeout(300);
}
async function fillNumber(page, label, value) {
if (value === null || value === undefined) return;
const input = page.locator(`input[aria-label="${label}"]`).first();
if (await input.count()) { await input.fill(String(value)); await input.press("Enter"); }
}
async function setCheckbox(page, label, checked) {
const box = page.locator(`input[type="checkbox"][aria-label="${label}"]`).first();
if (await box.count()) await box.setChecked(Boolean(checked)).catch(() => {});
}
/** Pick one option whose value is a JSON [object, subelement] reference. */
async function selectReference(page, locator, wanted) {
if (!wanted) return;
const object = typeof wanted === "string" ? wanted : wanted.object;
const sub = typeof wanted === "string" ? null : wanted.subelements?.[0] ?? wanted.subelement ?? null;
const match = await locator.evaluate((node, ref) => {
for (const option of node.options) {
try {
const parsed = JSON.parse(option.value);
const sameObject = parsed[0] === ref.object || `${parsed[0]}_${parsed[1]}` === ref.object;
if (sameObject && (!ref.sub || parsed[1] === ref.sub)) return option.value;
} catch { /* placeholder option text has no JSON value */ }
}
return null;
}, { object, sub });
if (!match) throw new Error(`no reference option for ${object}${sub ? "·" + sub : ""}`);
await locator.selectOption(match);
await page.waitForTimeout(300);
}
/** Apply Pad / Pocket / Revolution / Hole / Loft / Pipe through the profile group. */
export async function createFeature(page, step) {
await page.locator(`[role="group"][aria-label="Profile feature"] button[data-feature-type="${step.featureType}"]`).first().click();
await page.waitForTimeout(500);
// Select by the name the UI actually gave the sketch, not the kernel's name.
// A missing name must fail: picking "the last option" silently builds the
// wrong solid once a body holds more than one profile.
const profileName = step.uiProfile ?? step.profile;
if (profileName) {
const select = page.locator('select[aria-label="Feature Profile"]').first();
const values = await select.evaluate(node => [...node.options].map(option => option.value));
if (!values.includes(profileName)) throw new Error(`profile ${profileName} is not in the feature list`);
await select.selectOption(profileName);
await page.waitForTimeout(350);
}
if (step.length !== null && step.length !== undefined) {
const input = page.locator('input[aria-label="Feature Length"]').first();
if (await input.count()) { await input.fill(String(step.length)); await input.press("Enter"); }
}
if (step.featureType === "Revolution" && step.angle != null) {
const input = page.locator('input[aria-label="Feature Angle"]').first();
if (await input.count()) { await input.fill(String(step.angle)); await input.press("Enter"); }
}
// A Revolution without an axis spins the profile about an axis the form picked,
// which produces a completely different solid (shafts came out 16x too large).
// The axis select's values are JSON ["objectName","subelement"] pairs, so the
// kernel's single axis name has to be matched against the first element.
if (step.featureType === "Revolution") {
const axisSelect = page.locator('select[aria-label="Feature Axis"]').first();
if (await axisSelect.count()) {
const wanted = step.axis ?? "X_Axis";
const match = await axisSelect.evaluate((node, name) => {
for (const option of node.options) {
try {
const [object, sub] = JSON.parse(option.value);
if (object === name || `${object}_${sub}` === name || object === `${name}`.replace("_Axis", "")) return option.value;
} catch { /* placeholder option */ }
}
// Fall back to matching the visible label, which reads "X-axis · ".
const byLabel = [...node.options].find(option => option.textContent.trim().startsWith(name.replace("_", "-")));
return byLabel ? byLabel.value : null;
}, wanted);
if (match) { await axisSelect.selectOption(match); await page.waitForTimeout(300); }
else throw new Error(`no axis option for ${wanted}`);
}
}
// Midplane has no checkbox: it is the Sides select's "Symmetric" option. That
// select carries no aria-label and its options have no value attribute, so it
// has to be found by the label text ("Sides") rather than by a value filter.
const sides = page.locator('label:has(> select)').filter({ hasText: /^\s*Sides/ }).locator("select").first();
const mode = step.midplane ? "Symmetric" : "One side";
if (await sides.count()) {
await sides.selectOption({ label: mode });
await page.waitForTimeout(300);
}
// "Reversed" flips the extrusion direction of every profile feature the form
// draws it for. Hole carries its own copy inside fillFeatureExtras. Without
// this the flag was silently dropped and a pocket authored to cut upwards
// still cut downwards, so the built solid disagreed with the recorded
// reference while every step still "succeeded" (P05 CarrierHangar).
if (step.reversed !== undefined && ["Pad", "Pocket", "Revolution", "Groove"].includes(step.featureType)) {
await setCheckbox(page, "Reversed", step.reversed === true);
}
await fillFeatureExtras(page, step);
await page.locator('button[data-create-feature]').first().click();
await page.waitForTimeout(2500);
}
/** Fields that only exist for one feature type (Loft, Pipe, Hole). */
async function fillFeatureExtras(page, step) {
if (step.featureType === "Loft" || step.featureType === "SubtractiveLoft") {
const sections = (step.sections ?? []).map(section => (typeof section === "string" ? section : section?.object)).filter(Boolean);
if (sections.length) {
const picked = await selectMulti(page, page.locator('select[aria-label="Loft Sections"]').first(), sections);
if (picked.length !== sections.length) throw new Error(`loft sections missing: wanted ${sections.join(",")} got ${picked.join(",") || "none"}`);
}
await setCheckbox(page, "Loft Ruled", step.ruled === true);
await setCheckbox(page, "Loft Closed", step.closed === true);
return;
}
if (step.featureType === "Pipe" || step.featureType === "SubtractivePipe") {
const spine = step.spine ?? step.spineEdges?.[0] ?? null;
if (spine) {
const spineObject = typeof spine === "string" ? spine : spine.object;
const spineSelect = page.locator('select[aria-label="Pipe Spine"]').first();
if (await spineSelect.count()) {
const values = await spineSelect.evaluate(node => [...node.options].map(option => option.value));
const byValue = values.find(value => value === spineObject);
const byLabel = await spineSelect.evaluate((node, name) => {
const option = [...node.options].find(item => item.textContent.trim() === name
|| item.textContent.trim().startsWith(`${name} `));
return option ? option.value : null;
}, spineObject);
const chosen = byValue ?? byLabel;
if (chosen) await spineSelect.selectOption(chosen);
else throw new Error(`no pipe spine option for ${spineObject}`);
await page.waitForTimeout(300);
}
}
if (step.orientation) {
const orientation = page.locator('select[aria-label="Pipe Orientation"]').first();
if (await orientation.count()) await orientation.selectOption(step.orientation).catch(() => {});
}
if (step.transition) {
const transition = page.locator('select[aria-label="Pipe Transition"]').first();
if (await transition.count()) await transition.selectOption(step.transition).catch(() => {});
}
return;
}
if (step.featureType === "Hole") {
await fillNumber(page, "Hole Diameter", step.diameter);
if (step.depthType) {
const depthType = page.locator('select[aria-label="Hole Depth Type"]').first();
if (await depthType.count()) await depthType.selectOption(step.depthType).catch(() => {});
await page.waitForTimeout(200);
}
if (step.depthType !== "ThroughAll") await fillNumber(page, "Hole Depth", step.depth);
await setCheckbox(page, "Reversed", step.reversed === true);
}
}
/** Fillet / Chamfer through the dress-up group (inside a collapsed details). */
export async function createDressUp(page, step) {
await openDesignGroup(page, "厚度|布尔与边缘|Dress");
await page.locator(`[role="group"][aria-label="Dress-up feature"] button[data-dressup-type="${step.dressUpType}"]`).first().click();
await page.waitForTimeout(400);
if (step.base) {
const base = page.locator('select[aria-label="Dress-up Base"]').first();
if (await base.count()) {
const values = await base.evaluate(node => [...node.options].map(option => option.value));
if (!values.includes(step.base)) throw new Error(`dress-up base ${step.base} is not in the list`);
await base.selectOption(step.base);
await page.waitForTimeout(300);
}
}
await fillNumber(page, "Dress-up Size", step.size);
if (step.dressUpType === "Chamfer") {
if (step.chamferType) {
const type = page.locator('select[aria-label="Chamfer type"]').first();
if (await type.count()) await type.selectOption(step.chamferType).catch(() => {});
}
await fillNumber(page, "Chamfer second distance", step.size2);
await fillNumber(page, "Chamfer angle", step.angle);
await setCheckbox(page, "Chamfer Flip direction", step.flipDirection === true);
}
if (step.useAllEdges) await setCheckbox(page, "Use all edges", true);
else {
// Edge checkboxes are numbered EdgeN inside the native references group.
for (const edge of step.edges ?? []) {
const name = typeof edge === "string" ? edge : `Edge${edge.index ?? edge}`;
const box = page.locator(`input[type="checkbox"][aria-label="${name}"]`).first();
if (!(await box.count())) throw new Error(`no edge checkbox ${name}`);
await box.setChecked(true);
}
}
await page.waitForTimeout(300);
await page.locator('button[data-create-dressup]').first().click();
await page.waitForTimeout(2500);
}
/** Additive sphere primitive (bearing balls). */
export async function createPrimitive(page, step) {
const operation = page.locator('select[aria-label="Design primitive operation"]').first();
await operation.selectOption("Additive");
await page.locator('select[aria-label="Design primitive type"]').first().selectOption("Sphere");
await page.waitForTimeout(300);
if (step.parameters?.Radius != null) {
const radius = page.locator('input[aria-label="Design primitive Radius"]').first();
if (await radius.count()) await radius.fill(String(step.parameters.Radius));
}
for (const [index, axis] of ["X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="Design primitive position ${axis}"]`).first();
if (await input.count()) await input.fill(String(step.position?.[index] ?? 0));
}
await page.locator('button[aria-label="Create design primitive"]').first().click();
await page.waitForTimeout(2500);
}
/** Polar pattern (bearing balls). */
export async function createPolarPattern(page, step) {
// The transformation fieldset is inside a <details> that starts collapsed, so
// its controls exist in the DOM but cannot be clicked until the group opens.
await page.evaluate(() => {
for (const details of document.querySelectorAll("details.design-task-group")) {
const summary = details.querySelector("summary");
if (summary && /Transformation/i.test(summary.textContent ?? "")) details.open = true;
}
});
await page.waitForTimeout(300);
const originals = page.locator('select[aria-label="PolarPattern Originals"]').first();
const names = step.originals ?? [];
if (names.length) {
// Select by `value`, not by visible text: the option label is the object's
// display label, which need not equal the object name. A multi-select whose
// value never lands leaves the form invalid, so the commit button stays
// disabled and a blind click only times out.
const values = await originals.evaluate((node, wanted) => {
const picked = [...node.options].filter(option => wanted.includes(option.value)).map(option => option.value);
return picked.length ? picked : [...node.options].map(option => option.value).filter(Boolean);
}, names);
if (values.length) await originals.evaluate((node, picked) => {
for (const option of node.options) option.selected = picked.includes(option.value);
node.dispatchEvent(new Event("change", { bubbles: true }));
}, values);
await page.waitForTimeout(300);
}
if (step.angle != null) {
const angle = page.locator('input[aria-label="PolarPattern Angle"]').first();
if (await angle.count()) await angle.fill(String(step.angle));
}
// Without an axis the form keeps "Create PolarPattern" disabled, and a blind
// click then waits 30 s and reports a generic failure. The select's values are
// JSON ["object","subelement"] pairs, so match on the object name.
const wantedAxis = step.rotationAxis?.object;
if (wantedAxis) {
const axisSelect = page.locator('select[aria-label="PolarPattern Axis"]').first();
if (await axisSelect.count()) {
const match = await axisSelect.evaluate((node, name) => {
for (const option of node.options) {
try { if (JSON.parse(option.value)[0] === name) return option.value; } catch { /* placeholder */ }
}
return null;
}, wantedAxis);
if (match) { await axisSelect.selectOption(match); await page.waitForTimeout(300); }
else throw new Error(`no polar axis option for ${wantedAxis}`);
}
}
if (step.occurrences != null) {
const occurrences = page.locator('input[aria-label="PolarPattern Occurrences"]').first();
if (await occurrences.count()) await occurrences.fill(String(step.occurrences));
}
await page.locator('button[aria-label="Create PolarPattern"]').first().click();
await page.waitForTimeout(2500);
}
/**
* Volume of the body's current tip.
*
* The standalone page has no global object array; the property pane renders the
* selected feature's volume as text ("体积33600.000000"). Read that, and fall
* back to the tree's tip row when nothing is selected.
*/
export async function tipVolume(page) {
return page.evaluate(() => {
const pane = document.querySelector("aside.property-pane")?.textContent ?? "";
const match = /体积\s*(-?[\d.]+(?:[eE][-+]?\d+)?)/.exec(pane);
return match ? Number(match[1]) : null;
});
}
/** Try every feature tab until the property pane reports a volume. */
export async function selectTip(page) {
const rows = await page.locator('[role="treeitem"] .fc-tree-col-label').allTextContents();
for (const name of rows.reverse()) {
await page.locator(`[role="treeitem"] .fc-tree-col-label:text-is("${name}")`).first().click().catch(() => {});
await page.waitForTimeout(400);
if (await tipVolume(page) != null) return name;
}
return null;
}
/**
* Involute gear / sprocket. The Gear / Sprocket fieldset lives on the same
* `partdesign.html` page as the sketch editor, so no page hop is needed; the
* fields are `Gear <parameterName>` and the commit button has no data hook, so
* it is found by its visible label.
*/
export async function createGear(page, step) {
// The gear fieldset lives inside a collapsed <details> task group, so the
// select exists in the DOM but is not interactable until the group is opened.
await page.evaluate(() => {
for (const details of document.querySelectorAll("details.design-task-group")) {
const summary = details.querySelector("summary");
if (summary && /Gear/i.test(summary.textContent ?? "")) details.open = true;
}
});
await page.waitForTimeout(300);
const kind = step.gearType === "Sprocket" ? "Sprocket" : "InvoluteGear";
await page.locator('select[aria-label="Gear type"]').first().selectOption(kind);
await page.waitForTimeout(400);
for (const [key, value] of Object.entries(step.gearParameters ?? {})) {
if (typeof value === "boolean") {
const box = page.locator(`input[type="checkbox"][aria-label="Gear ${key}"]`).first();
if (await box.count()) await box.setChecked(value).catch(() => {});
continue;
}
if (typeof value !== "number") continue;
const input = page.locator(`input[aria-label="Gear ${key}"]`).first();
if (await input.count()) { await input.fill(String(value)); await input.press("Enter"); }
}
// Position and orientation: a gear body sits at an axial offset and often
// faces along Y, so the placement is part of the operation, not a nicety.
for (const [index, axis] of ["X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="Gear position ${axis}"]`).first();
if (await input.count()) { await input.fill(String(step.position?.[index] ?? 0)); await input.press("Enter"); }
}
const gearPlane = page.locator('select[aria-label="Gear plane"]').first();
if (await gearPlane.count()) {
const rotation = step.placementRotation ?? [0, 0, 0, 1];
const identity = rotation[0] === 0 && rotation[1] === 0 && rotation[2] === 0;
if (identity) await gearPlane.selectOption("XY");
else {
await gearPlane.selectOption("Custom");
for (const [index, axis] of ["W", "X", "Y", "Z"].entries()) {
const input = page.locator(`input[aria-label="Gear rotation ${axis}"]`).first();
if (await input.count()) { await input.fill(String(rotation[index])); await input.press("Enter"); }
}
}
await page.waitForTimeout(200);
}
const commit = page.getByRole("button", { name: /^Create gear$/ }).first();
await commit.click();
await page.waitForTimeout(2500);
}
/** Mirrored: originals + plane, then "Create Mirrored". */
export async function createMirrored(page, step) {
await openDesignGroup(page, "Transformation");
const originals = page.locator('select[aria-label="Mirrored Originals"]').first();
const names = step.originals ?? [];
if (names.length) {
const picked = await selectMulti(page, originals, names);
if (!picked.length) throw new Error(`mirrored originals missing: ${names.join(",")}`);
}
await selectReference(page, page.locator('select[aria-label="Mirrored Plane"]').first(), step.mirrorPlane);
const commit = page.locator('button[aria-label="Create Mirrored"]').first();
await commit.waitFor({ state: "visible", timeout: 15000 });
await commit.click();
await page.waitForTimeout(2500);
}
/** LinearPattern: originals + direction + length + occurrences. */
export async function createLinearPattern(page, step) {
await openDesignGroup(page, "Transformation");
const originals = page.locator('select[aria-label="LinearPattern Originals"]').first();
const names = step.originals ?? [];
if (names.length) {
const picked = await selectMulti(page, originals, names);
if (!picked.length) throw new Error(`linear pattern originals missing: ${names.join(",")}`);
}
await selectReference(page, page.locator('select[aria-label="LinearPattern Direction"]').first(), step.direction);
await fillNumber(page, "LinearPattern Length", step.length);
await fillNumber(page, "LinearPattern Occurrences", step.occurrences);
await setCheckbox(page, "LinearPattern Reversed", step.reversed === true);
const occurrences = page.locator('input[aria-label="LinearPattern Occurrences"]').first();
if (await occurrences.count()) await occurrences.press("Enter");
await page.locator('button[aria-label="Create LinearPattern"]').first().click();
await page.waitForTimeout(2500);
}
export async function createTransform(page, step) {
if (step.transformType === "Mirrored") return createMirrored(page, step);
if (step.transformType === "LinearPattern") return createLinearPattern(page, step);
return createPolarPattern(page, step);
}
export async function runStep(page, step) {
if (step.kind === "sketch") return createSketch(page, step);
if (step.kind === "gear") return createGear(page, step);
if (step.kind === "feature") return createFeature(page, step);
if (step.kind === "primitive") return createPrimitive(page, step);
if (step.kind === "transform") return createTransform(page, step);
if (step.kind === "dressup") return createDressUp(page, step);
throw new Error(`ui-driver cannot perform kind "${step.kind}" (${step.label})`);
}

View File

@@ -0,0 +1,80 @@
// Normalize a project's build records into one shape.
//
// Two record formats exist in this repository and both are real evidence, so
// the tool has to read either rather than force every project to re-record:
//
// freecad-web-*/replay/v1 { steps: [ { step, label, action, args, volume } ] }
// freecad-web-process-trace/v1 { events: [ { step, label, action, args, tips } ] }
//
// The only shape difference that matters downstream is the per-step volume:
// the replay format carries it directly, the trace format only carries a whole
// document listing (`tips.objects`) and the volume of the progressive body must
// be picked out of it. A missing volume is legitimate -- a sketch step builds no
// solid -- and is passed through as null rather than invented.
import fs from "node:fs";
const STEP_LIST_KEYS = ["steps", "events"];
// Actions that leave a solid in the Body. Everything else (setSketch, a datum,
// a parameter edit) touches no geometry, so it has no volume to compare.
const SOLID_ACTIONS = new Set(["setFeature", "setGear", "setPrimitive", "setTransform", "setDressUp"]);
function isSolidStep(action) {
return SOLID_ACTIONS.has(String(action ?? ""));
}
function stepVolume(entry) {
return typeof entry.volume === "number" ? entry.volume : bodyVolume(entry.tips);
}
/** Volume of the accumulating body, which is what each step is asserted against. */
function bodyVolume(tips) {
const objects = tips?.objects ?? [];
const body = objects.find(object => object?.type === "PartDesign::Body");
if (body) return typeof body.volume === "number" ? body.volume : null;
// Documents without a Body (a bare Part::Feature, a primitive placed straight
// into the document) report the volume on the tip feature itself.
const tip = tips?.tip;
if (tip && typeof tip.volume === "number") return tip.volume;
return null;
}
/**
* Read one document's build record from disk and return `{ document, steps }`.
* Throws when the file is not a record this tool understands, so a wrong path
* fails immediately instead of producing a plausible empty run.
*/
export function readReplay(file) {
let text;
try { text = fs.readFileSync(file, "utf8"); }
catch (error) { throw new Error(`${file}: ${error.message}`); }
let record;
try { record = JSON.parse(text); }
catch (error) { throw new Error(`${file}: not valid JSON (${error.message})`); }
return normalizeReplay(record, file);
}
/** Normalize an already-parsed record. */
export function normalizeReplay(record, label = "replay") {
if (!record || typeof record !== "object") throw new Error(`${label}: not an object`);
const key = STEP_LIST_KEYS.find(name => Array.isArray(record[name]));
if (!key) throw new Error(`${label}: has neither steps nor events; schema ${record.schema ?? "unknown"}`);
const steps = record[key].map((entry, index) => {
const step = entry.step ?? String(index + 1);
return {
step,
label: entry.label ?? `step ${step}`,
action: entry.action,
args: entry.args ?? {},
// Prefer the record's own per-step volume; fall back to the body listing.
//
// A sketch step builds no solid, and the trace format records the
// *carried* body volume on it rather than 0 or null. That number belongs
// to the previous feature, so asserting a sketch against it fails on every
// sketch in the document. Only feature-like actions carry a solid.
volume: isSolidStep(entry.action) ? stepVolume(entry) : null,
};
});
return { schema: record.schema ?? null, document: record.document ?? null, source: key, steps };
}

View File

@@ -0,0 +1,225 @@
// Turn a finished part into the exact list of UI operations that would rebuild it.
//
// The replay records each step's action and arguments, but it deliberately
// compacts sketches to {count, sha256}: a trace should not carry thousands of
// coordinates. The finished FCStd still holds them, and the kernel's snapshot
// dumps every sketch's real geometry and constraints (PartDesignDocumentWorkflow
// .cpp:1101-1150). So the UI instructions are generated from the same document
// the videos render, never retyped by hand.
/**
* Default page per command kind.
*
* The standalone PartDesign workspace is the only page that renders both the
* sketch editor and the profile features, so every kind defaults to it. The old
* copy of this table sent gears to workbench.html while the driver had already
* moved gears onto partdesign.html — a project can still override any entry
* through `project.json`'s `pages`.
*/
export const PAGE_FOR = {
sketch: "partdesign.html",
feature: "partdesign.html",
gear: "partdesign.html",
primitive: "partdesign.html",
transform: "partdesign.html",
dressup: "partdesign.html",
};
const FEATURE_COMMAND = {
Pad: "PartDesign_Pad",
Pocket: "PartDesign_Pocket",
Revolution: "PartDesign_Revolution",
Groove: "PartDesign_Groove",
Hole: "PartDesign_Hole",
Loft: "PartDesign_AdditiveLoft",
Pipe: "PartDesign_AdditivePipe",
Helix: "PartDesign_AdditiveHelix",
SubtractiveLoft: "PartDesign_SubtractiveLoft",
SubtractivePipe: "PartDesign_SubtractivePipe",
SubtractiveHelix: "PartDesign_SubtractiveHelix",
Boolean: "PartDesign_Boolean",
};
const TRANSFORM_COMMAND = {
PolarPattern: "PartDesign_PolarPattern",
LinearPattern: "PartDesign_LinearPattern",
Mirrored: "PartDesign_Mirrored",
Scaled: "PartDesign_Scaled",
};
/**
* Feature arguments that must survive into the UI step untouched.
*
* The panel names differ per feature type, but the replay already records them
* under the kernel's own keys (`setFeature` accepts them verbatim), so copying
* the known set is enough and keeps one table instead of one builder per type.
*/
const FEATURE_EXTRA = [
"sections", "ruled", "closed",
"spine", "spineEdges", "pipeMode", "transition", "referenceMode",
"auxiliarySpine", "auxiliarySpineEdges", "auxiliaryCurvilinear", "binormal",
"diameter", "depth", "depthType",
];
const DRESS_UP_COMMAND = { Fillet: "PartDesign_Fillet", Chamfer: "PartDesign_Chamfer" };
/** Round to 1e-4 mm: finer than any drawing tolerance, and keeps the text short. */
// Round only to kill float noise; 4 decimals broke arc closure (pi -> 3.1416
// leaves a 1.6e-4 mm gap at r=41, far outside OCCT's 1e-7 confusion).
const r4 = value => Math.round(Number(value) * 1e9) / 1e9;
const triple = value => (Array.isArray(value) ? value.slice(0, 3).map(r4) : null);
/**
* Describe one sketch for the geometry+constraint editor.
*
* The editor is laid out as rows: `Geometry N type` plus X/Y/Z (and radius or
* angles), then `Constraint N type` plus its geometry/point slots. Keeping the
* row order identical to the kernel's own means the numbering the learner reads
* matches the numbering the kernel reported.
*/
export function describeSketch(sketch) {
const geometries = (sketch.geometries ?? []).map(geometry => {
const row = { type: geometry.type };
if (geometry.type === "line") { row.start = triple(geometry.start); row.end = triple(geometry.end); }
else if (geometry.type === "circle") { row.center = triple(geometry.center); row.radius = r4(geometry.radius); }
else if (geometry.type === "arc") {
row.center = triple(geometry.center); row.radius = r4(geometry.radius);
row.startAngle = r4(geometry.startAngle); row.endAngle = r4(geometry.endAngle);
} else if (geometry.type === "ellipse") {
row.center = triple(geometry.center); row.majorRadius = r4(geometry.majorRadius);
row.minorRadius = r4(geometry.minorRadius);
} else if (geometry.type === "point") { row.point = triple(geometry.point); }
else if (geometry.type === "bspline") row.points = (geometry.points ?? []).map(triple);
return row;
});
const constraints = (sketch.constraints ?? []).map(constraint => {
const row = { type: constraint.type };
for (const key of ["first", "second", "third"]) if (constraint[key] != null) row[key] = constraint[key];
for (const key of ["firstPos", "secondPos", "thirdPos"]) {
if (constraint[key] && constraint[key] !== "none") row[key] = constraint[key];
}
if (constraint.value != null) row.value = r4(constraint.value);
if (constraint.name) row.name = constraint.name;
return row;
});
return {
profileType: sketch.profileType ?? "Geometry",
position: triple(sketch.position) ?? [0, 0, 0],
// Sketches are not always parallel to XY. Bolt patterns on a Y-facing face
// need a rotated support plane; the kernel snapshot now reports it and
// `setSketch` accepts it.
placementRotation: Array.isArray(sketch.placementRotation)
? sketch.placementRotation.map(r4) : [0, 0, 0, 1],
// Named constraints carry the dimensions of the simple profiles: a Circle
// sketch has no geometry list at all, its radius IS the named constraint
// "Radius" (the same conflation desktop Sketcher uses). Dropping this made
// every Circle sketch non-reproducible.
parameters: Object.fromEntries(Object.entries(sketch.parameters ?? {}).map(([key, value]) => [key, r4(value)])),
geometries, constraints,
};
}
/**
* Build the UI step list for one document from its replay and a kernel snapshot.
* @param {object} [options] `pages` and `featureCommands` from the project
* manifest; anything absent falls back to the defaults above.
*/
export function uiStepsFor(document, replay, snapshotObjects, options = {}) {
const pages = { ...PAGE_FOR, ...(options.pages ?? {}) };
const featureCommands = { ...FEATURE_COMMAND, ...(options.featureCommands ?? {}) };
const sketches = new Map();
for (const object of snapshotObjects ?? []) {
if (object.type === "Sketcher::SketchObject") sketches.set(object.name, object);
}
const failures = [];
const steps = [];
for (const [index, step] of replay.steps.entries()) {
const args = step.args ?? {};
const objectName = args.object;
const base = { step: step.step, label: step.label, action: step.action, object: objectName ?? null };
if (step.action === "setSketch") {
const sketch = sketches.get(objectName);
if (!sketch) { failures.push(`${document} step ${step.step}: sketch ${objectName} not in the document`); continue; }
const described = describeSketch(sketch);
// The replay's digest is the contract that these are the same arrays.
if (args.geometries && typeof args.geometries === "object" && "count" in args.geometries
&& args.geometries.count !== described.geometries.length)
failures.push(`${document} step ${step.step}: ${described.geometries.length} geometries but the trace recorded ${args.geometries.count}`);
// A simple profile without its dimension cannot be reproduced by hand.
if (described.profileType === "Circle" && !(described.parameters?.Radius > 0))
failures.push(`${document} step ${step.step}: Circle sketch ${objectName} has no Radius`);
if (described.profileType === "Rectangle" && !(described.parameters?.Width > 0 && described.parameters?.Height > 0))
failures.push(`${document} step ${step.step}: Rectangle sketch ${objectName} lacks Width/Height`);
steps.push({
...base, kind: "sketch", page: pages.sketch, command: "PartDesign_NewSketch",
profileType: described.profileType, position: described.position,
placementRotation: described.placementRotation,
parameters: described.parameters,
geometries: described.geometries, constraints: described.constraints,
requireFullyConstrained: false,
});
} else if (step.action === "setFeature") {
const command = featureCommands[args.featureType];
if (!command) { failures.push(`${document} step ${step.step}: unknown featureType ${args.featureType}`); continue; }
const extra = {};
for (const key of FEATURE_EXTRA) if (args[key] !== undefined) extra[key] = args[key];
steps.push({
...base, kind: "feature", page: pages.feature, command,
featureType: args.featureType, profile: args.profile ?? null, profileType: null,
position: null, geometries: [], constraints: [],
length: args.length ?? null, midplane: args.midplane === true, reversed: args.reversed === true,
angle: args.angle ?? (args.featureType === "Revolution" ? 360 : null), axis: args.axis ?? null,
...extra,
});
} else if (step.action === "setGear") {
steps.push({
...base, kind: "gear", page: pages.gear, command: "PartDesign_InvoluteGear",
gearType: args.gearType, gearParameters: args.gearParameters ?? {},
position: triple(args.position) ?? [0, 0, 0],
placementRotation: Array.isArray(args.placementRotation)
? args.placementRotation.map(r4) : [0, 0, 0, 1],
geometries: [], constraints: [],
});
} else if (step.action === "setPrimitive") {
steps.push({
...base, kind: "primitive", page: pages.primitive, command: "PartDesign_AdditiveSphere",
primitiveType: args.primitiveType, parameters: args.parameters ?? {},
position: triple(args.position) ?? [0, 0, 0], geometries: [], constraints: [],
});
} else if (step.action === "setTransform") {
// Older records omit transformType; they were all polar patterns, and the
// driver branches on this field, so defaulting keeps them identical.
const transformType = args.transformType ?? "PolarPattern";
const command = TRANSFORM_COMMAND[transformType];
if (!command) { failures.push(`${document} step ${step.step}: unknown transformType ${transformType}`); continue; }
steps.push({
...base, kind: "transform", page: pages.transform, command,
transformType, originals: args.originals ?? [],
occurrences: args.occurrences ?? null, angle: args.angle ?? null,
rotationAxis: args.rotationAxis ?? null,
mirrorPlane: args.mirrorPlane ?? null, direction: args.direction ?? null,
length: args.length ?? null, reversed: args.reversed === true,
geometries: [], constraints: [],
});
} else if (step.action === "setDressUp") {
const command = DRESS_UP_COMMAND[args.dressUpType];
if (!command) { failures.push(`${document} step ${step.step}: unknown dressUpType ${args.dressUpType}`); continue; }
steps.push({
...base, kind: "dressup", page: pages.dressup, command,
dressUpType: args.dressUpType, base: args.base ?? null,
size: args.size ?? null, edges: args.edges ?? [],
useAllEdges: args.useAllEdges === true,
chamferType: args.chamferType ?? null, size2: args.size2 ?? null,
angle: args.angle ?? null, flipDirection: args.flipDirection === true,
geometries: [], constraints: [],
});
} else {
failures.push(`${document} step ${step.step}: unhandled action ${step.action}`);
continue;
}
void index;
}
return { document, steps, failures };
}

View File

@@ -0,0 +1,41 @@
// Where a step's screenshot is written, and what it is called.
//
// The writer (drive.mjs) and the checker (accept.mjs) must agree exactly, or a
// project that never had a video pipeline gets a false "missing still" for
// every step. A course script, when present, supplies the scene id and title;
// without one the step number is enough. Both sides call these helpers.
import fs from "node:fs";
import path from "node:path";
/** Scene id for step index (0-based): `S01` unless a course script says otherwise. */
export function sceneId(project, part, index, steps) {
const declared = part.sceneTitles?.[index + 1];
if (declared) return declared;
const script = readScript(project, part);
const hit = script?.scenes?.find(item => item.step === index + 1);
return hit?.id ?? `S${String(index + 1).padStart(2, "0")}`;
}
/** Human title for a step, used inside the filename. */
export function sceneTitle(project, part, index, steps) {
const script = readScript(project, part);
return script?.scenes?.find(item => item.step === index + 1)?.title
?? steps[index]?.label ?? `step ${index + 1}`;
}
/** Filename stem (no extension) for a step's still. */
export function stillName(project, part, index, steps) {
const title = String(sceneTitle(project, part, index, steps)).replace(/[^\w一-龥-]+/g, "_");
return `${sceneId(project, part, index, steps)}-${title}`;
}
/** Absolute path a step's still is written to. */
export function stillPath(project, part, index, steps) {
return path.join(project.paths.stillsDir, part.id, `${stillName(project, part, index, steps)}.png`);
}
function readScript(project, part) {
const file = path.join(project.root, "episodes", part.id, "script.zh.json");
if (!fs.existsSync(file)) return null;
try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
}

View File

@@ -0,0 +1,158 @@
#!/usr/bin/env node
// Project manifest: the only thing a new project has to write.
//
// Every runner in this directory takes `--project <dir>` and reads
// `<dir>/project.json`. Nothing here may assume a project name, an episode id
// format, or a directory layout: those are exactly the couplings that made the
// original reducer scripts non-reusable.
//
// A manifest is validated eagerly so a typo fails in a tenth of a second
// instead of after two minutes of browser startup.
import fs from "node:fs";
import path from "node:path";
export const MANIFEST_SCHEMA = "freecad-web-cad-ui-rebuild/project/v1";
// The standalone PartDesign workspace is the only page that carries both the
// sketch editor and the profile features, so it is the correct default for
// every modelling kind. A project can override any of them.
const DEFAULT_PAGES = {
sketch: "partdesign.html",
feature: "partdesign.html",
gear: "partdesign.html",
primitive: "partdesign.html",
transform: "partdesign.html",
// assembly.html is the kernel probe's fixture page, not a workbench: the
// Create/Insert tasks mount on the workbench surface, keyed by command.
assembly: "workbench.html?module=Assembly&command=Assembly_CreateAssembly",
};
const DEFAULT_FEATURE_COMMANDS = {
Pad: "PartDesign_Pad",
Pocket: "PartDesign_Pocket",
Revolution: "PartDesign_Revolution",
Groove: "PartDesign_Groove",
};
const fail = message => {
const error = new Error(message);
error.isPrerequisite = true; // a bad manifest is a setup problem, not a product defect
throw error;
};
const resolveFrom = (base, value) => (path.isAbsolute(value) ? value : path.resolve(base, value));
/**
* Load and validate a project manifest.
*
* `--project` accepts either a directory holding `project.json` or the manifest
* file itself, so a project's config can live anywhere (this tool keeps the
* ones it ships in `projects/`) without inventing a second flag.
*
* @param {string} projectPath absolute path to the project directory or its .json
* @param {{requireParts?: boolean, requireAssembly?: boolean}} options
*/
export function loadProject(projectPath, options = {}) {
const resolved = path.resolve(projectPath);
const isFile = /\.json$/i.test(resolved);
const file = isFile ? resolved : path.join(resolved, "project.json");
const root = isFile ? path.dirname(resolved) : resolved;
if (!fs.existsSync(file)) fail(`no manifest at ${file}`);
let raw;
try {
raw = JSON.parse(fs.readFileSync(file, "utf8"));
} catch (error) {
fail(`project.json is not valid JSON: ${error.message}`);
}
if (raw.schema && raw.schema !== MANIFEST_SCHEMA) {
fail(`project.json schema is ${raw.schema}, expected ${MANIFEST_SCHEMA}`);
}
if (!raw.name) fail("project.json needs a name");
const paths = raw.paths ?? {};
const outDir = resolveFrom(root, paths.outDir ?? "out");
const project = {
name: raw.name,
root,
appOrigin: raw.appOrigin ?? "http://127.0.0.1:5180",
pages: { ...DEFAULT_PAGES, ...(raw.pages ?? {}) },
featureCommands: { ...DEFAULT_FEATURE_COMMANDS, ...(raw.featureCommands ?? {}) },
paths: {
replayDir: paths.replayDir ? resolveFrom(root, paths.replayDir) : null,
// Records are not always named `<document>.json`: one project prefixes
// them (`trace-<document>.json`). `{document}` is substituted; the
// default matches the records this tool itself writes.
replayName: paths.replayName ?? "{document}.json",
assemblyReplayName: paths.assemblyReplayName ?? paths.replayName ?? "{document}.json",
sampleDir: paths.sampleDir ? resolveFrom(root, paths.sampleDir) : null,
outDir,
stepsDir: path.join(outDir, "ui-steps"),
runDir: path.join(outDir, "ui-run"),
stillsDir: resolveFrom(root, paths.stillsDir ?? "ui-stills"),
},
parts: (raw.parts ?? []).map(part => {
if (!part.id) fail("every part needs an id");
if (!part.document) fail(`part ${part.id} needs a document`);
return {
id: String(part.id),
document: String(part.document),
title: part.title ?? String(part.document),
// Optional: which scene ids belong to which kernel step. Without it the
// driver names stills by step number instead of the course scene id.
sceneTitles: part.sceneTitles ?? null,
};
}),
assembly: raw.assembly ?? null,
};
if (options.requireParts && !project.parts.length) fail("project.json has no parts");
if (options.requireParts && !project.paths.replayDir) fail("project.json needs paths.replayDir to read replays");
if (options.requireAssembly) {
if (!project.assembly) fail("project.json has no assembly block");
if (!project.assembly.document) fail("assembly block needs a document name");
}
// Part ids are used as directory names, so reject anything path-hostile.
for (const part of project.parts) {
if (!/^[\w.-]+$/.test(part.id)) fail(`part id "${part.id}" must be letters, digits, dot, dash or underscore`);
}
const duplicates = project.parts.filter((part, index) => project.parts.findIndex(other => other.id === part.id) !== index);
if (duplicates.length) fail(`duplicate part ids: ${duplicates.map(part => part.id).join(", ")}`);
return project;
}
/** Path of one record in the project's replay directory, honouring the name pattern. */
export function replayPath(project, document, { assembly = false } = {}) {
if (!project.paths.replayDir) fail(`project ${project.name} has no paths.replayDir`);
const pattern = assembly ? project.paths.assemblyReplayName : project.paths.replayName;
return path.join(project.paths.replayDir, pattern.replace("{document}", document));
}
/** Resolve `--project` from argv, defaulting to the current directory. */
export function projectFromArgv(argv = process.argv.slice(2), fallback = process.cwd()) {
const index = argv.indexOf("--project");
const value = index >= 0 ? argv[index + 1] : fallback;
if (!value) fail("--project <dir> is required");
return path.resolve(value);
}
/** Read one JSON file, returning null when it is absent. */
export function readJson(file) {
return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")) : null;
}
/** `manifest.mjs --project <dir>` prints the part ids, one per line (used by sweep.sh). */
if (import.meta.url === `file://${process.argv[1]}`) {
const project = loadProject(projectFromArgv(), { requireParts: true });
for (const part of project.parts) console.log(part.id);
process.exit(0);
}
/** Locate a part by id or document name. */
export function findPart(project, key) {
const part = project.parts.find(item => item.id === key || item.document === key);
if (!part) fail(`project ${project.name} has no part "${key}"`);
return part;
}

View File

@@ -0,0 +1,42 @@
# 工程清单目录
每个 `*.json` 是一个工程的接入清单(schema `freecad-web-cad-ui-rebuild/project/v1`),
直接传给工具的 `--project`:
```bash
node ../build-steps.mjs --project projects/secondary-reducer-pro.json
```
| 清单 | 工程 | 构建记录格式 | 零件 |
|---|---|---|---|
| `secondary-reducer-pro.json` | `teaching/cases/secondary-reducer-pro` | `replay/v1`(`steps`,每步带 `volume`) | 23 |
| `secondary-reducer.json` | `teaching/cases/secondary-reducer`(上一代) | `process-trace/v1`(`events`,体积取自 `tips`) | 23 |
两份清单覆盖了仓库里现存的两代构建记录格式。工具通过 `lib/replay.mjs`
归一化二者,所以新工程无论用哪种格式都能直接接入。
`paths.replayName` 指定记录文件名,`{document}` 会被替换;默认 `<document>.json`。
若某个工程的记录另有命名(例如旧工程用 `trace-<document>.json`),在清单里写
`"replayName": "trace-{document}.json"` 即可,无需改代码。
`paths` 里的相对路径以**本目录**为基准。产物(`out/`、`ui-stills/`)写在清单
所在目录下;若想让产物落到工程自己的目录,把 `outDir` / `stillsDir` 写成绝对路径
或相对本目录的路径即可。
## 第二份清单证明了什么
两份清单不是复制品:它们喂给工具的输入形态不同。
| | `secondary-reducer-pro` | `secondary-reducer` |
|---|---|---|
| 记录键 | `steps[]`,每步直接带 `volume` | `events[]`,体积要从 `tips.objects` 里取 `PartDesign::Body` |
| 记录文件名 | `<document>.json` | `trace-<document>.json` |
| 有装配回放 | 是 | 否 |
| 有教案脚本 | 是(截图按场景编号命名) | 否(截图按步号 `S01` 命名) |
三处差异各自对应一处曾经写死的假设,现在都改成了清单里的选项:
`lib/replay.mjs` 归一化两种记录格式,`paths.replayName` 处理文件名,
`lib/stills.mjs` 让写入方和校验方共用一套命名(缺教案脚本时退回步号)。
**验证**:`build-steps.mjs --project projects/secondary-reducer.json`
→ 23 件 / 104 步 / 0 失败;逐件 `drive.mjs` 走出与记录一致的体积。

View File

@@ -0,0 +1,42 @@
{
"schema": "freecad-web-cad-ui-rebuild/ui-run/v1",
"generatedAt": "2026-11-19T12:01:44.026Z",
"project": "secondary-reducer",
"episode": "R01",
"document": "Bearing6206_Balls",
"steps": 2,
"stepsTotal": 2,
"failed": 0,
"volume": 4040.284502,
"expected": 4040.2845020573213,
"relativeError": 1.4187455932224955e-11,
"volumeMatches": true,
"seconds": 103.933,
"pageErrors": [],
"results": [
{
"step": 1,
"label": "ball",
"kind": "primitive",
"command": "PartDesign_AdditiveSphere",
"uiName": null,
"volume": 448.9205,
"expectedVolume": 448.9205002285916,
"volumeMatches": true,
"status": "ok",
"ms": 33507
},
{
"step": 2,
"label": "ball pattern",
"kind": "transform",
"command": "PartDesign_PolarPattern",
"uiName": null,
"volume": 4040.284502,
"expectedVolume": 4040.2845020573213,
"volumeMatches": true,
"status": "ok",
"ms": 34117
}
]
}

View File

@@ -0,0 +1,42 @@
{
"schema": "freecad-web-cad-ui-rebuild/ui-run/v1",
"generatedAt": "2026-11-19T12:06:13.358Z",
"project": "secondary-reducer",
"episode": "R02",
"document": "Bearing6206_Inner",
"steps": 2,
"stepsTotal": 2,
"failed": 0,
"volume": 6994.001612,
"expected": 6994.001611914469,
"relativeError": 1.2229150848124753e-11,
"volumeMatches": true,
"seconds": 109.348,
"pageErrors": [],
"results": [
{
"step": 1,
"label": "profile",
"kind": "sketch",
"command": "PartDesign_NewSketch",
"uiName": "Sketch1",
"volume": 0,
"expectedVolume": null,
"volumeMatches": null,
"status": "ok",
"ms": 38870
},
{
"step": 2,
"label": "revolution",
"kind": "feature",
"command": "PartDesign_Revolution",
"uiName": null,
"volume": 6994.001612,
"expectedVolume": 6994.001611914469,
"volumeMatches": true,
"status": "ok",
"ms": 34428
}
]
}

View File

@@ -0,0 +1,42 @@
{
"schema": "freecad-web-cad-ui-rebuild/ui-run/v1",
"generatedAt": "2026-11-19T12:13:38.702Z",
"project": "secondary-reducer",
"episode": "R03",
"document": "Bearing6206_Outer",
"steps": 2,
"stepsTotal": 2,
"failed": 0,
"volume": 11855.480945,
"expected": 11855.480944361034,
"relativeError": 5.389621102081815e-11,
"volumeMatches": true,
"seconds": 115.261,
"pageErrors": [],
"results": [
{
"step": 1,
"label": "profile",
"kind": "sketch",
"command": "PartDesign_NewSketch",
"uiName": "Sketch1",
"volume": 0,
"expectedVolume": null,
"volumeMatches": null,
"status": "ok",
"ms": 39696
},
{
"step": 2,
"label": "revolution",
"kind": "feature",
"command": "PartDesign_Revolution",
"uiName": null,
"volume": 11855.480945,
"expectedVolume": 11855.480944361034,
"volumeMatches": true,
"status": "ok",
"ms": 34488
}
]
}

Some files were not shown because too many files have changed in this diff Show More