@coloopx/colocad 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +2 -0
- package/README.md +109 -2
- package/README.zh-CN.md +129 -0
- package/bin/colocad.mjs +28 -4
- package/docs/README.md +27 -0
- package/docs/README.zh-CN.md +81 -0
- package/docs/modeling-history.md +60 -0
- package/examples/hiwin-kk60/README.md +55 -0
- package/examples/hiwin-kk60/model.mjs +94 -0
- package/examples/hiwin-kk60/run.mjs +14 -0
- package/examples/hiwin-kk60/sources.json +88 -0
- package/kernel/native/darwin-arm64/agent-cad +2 -2
- package/kernel/native/darwin-arm64/manifest.json +2 -3
- package/kernel/native/linux-arm64/agent-cad +1 -1
- package/kernel/native/linux-arm64/manifest.json +2 -3
- package/kernel/native/linux-x64/agent-cad +2 -2
- package/kernel/native/linux-x64/manifest.json +2 -3
- package/kernel/release.json +8 -0
- package/package.json +42 -4
- package/scripts/check-release.mjs +24 -0
- package/skills/colocad/SKILL.md +19 -0
- package/skills/colocad/assets/angle-bracket.json +39 -0
- package/skills/colocad/assets/ball.json +16 -0
- package/skills/colocad/assets/block.json +18 -0
- package/skills/colocad/assets/open-housing.json +35 -0
- package/skills/colocad/assets/pin.json +18 -0
- package/skills/colocad/assets/plate-grid.json +34 -0
- package/skills/colocad/assets/sleeve.json +19 -0
- package/skills/colocad/assets/taper.json +20 -0
- package/skills/colocad/references/history.md +19 -0
- package/skills/colocad/references/quick-build.md +44 -0
- package/skills/colocad/scripts/assembly.mjs +3 -0
- package/skills/colocad/scripts/build.mjs +54 -0
- package/src/render.mjs +72 -0
- package/src/session.d.mts +34 -0
- package/src/session.mjs +140 -0
- package/src/view-server.mjs +50 -0
- package/viewer/THREE-LICENSE +21 -0
- package/viewer/dist/index.js +4236 -0
- package/viewer/dist/standalone.js +4236 -0
- package/viewer/index.d.ts +18 -0
package/NOTICE.md
CHANGED
|
@@ -3,3 +3,5 @@
|
|
|
3
3
|
Colocad and the included Agent CAD application code are distributed under the MIT license. The Rust application builds against SolidCore at revision bff1569a4c3347ed9af67faab71578cadf84fde2. SolidCore includes work derived from NVIDIA USD BRep / SMLib. The kernel's Apache-2.0 license, notices, attribution and licenses of Rust dependencies ship in `kernel/licenses`. Source provenance is also recorded in `third_party`.
|
|
4
4
|
|
|
5
5
|
The .NET author references SOLIDWORKS 2024 interop APIs. SOLIDWORKS is a trademark of its respective owner. A local licensed installation provides the proprietary COM application and its interop assemblies. The package contains Colocad's own managed assembly and source in the repository. The experimental file-format investigation uses the independently licensed cadmpeg project at d77e2dd2a9d154e7b432afb022c147864f2618bb.
|
|
6
|
+
|
|
7
|
+
The browser viewer bundles Three.js under the MIT license; its license is included in `viewer/THREE-LICENSE`. HIWIN and product names in the actuator reconstruction identify the source product; this project is not affiliated with or endorsed by the manufacturer. No manufacturer CAD or catalog PDF is redistributed.
|
package/README.md
CHANGED
|
@@ -1,8 +1,115 @@
|
|
|
1
1
|
# colocad
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文说明](README.zh-CN.md) · [Developer docs](docs/README.md) · [npm package](https://www.npmjs.com/package/@coloopx/colocad) · [Download the offline comparison](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/comparison.html)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generate a mechanical part from a JSON feature tree, export an exact STEP solid, and give an agent a PNG or 3D preview to inspect. **The npm package ships the compiled Rust CAD kernel.** The agent and harness call it locally in the same sandbox through the Node CLI or TypeScript API. No Python, Rust toolchain, network or separate service is required to build a part after installation.
|
|
6
|
+
|
|
7
|
+
## Reconstruct a real industrial product and replay its modeling history
|
|
8
|
+
|
|
9
|
+
The [HIWIN KK60 actuator example](examples/hiwin-kk60/README.md) reconstructs a specific manufacturer catalog configuration: 300 mm rail, 5 mm lead, 210 mm travel. Its **52 native features, 81 named occurrences and 16 persisted milestones** include a physically cut helical screw groove, guide tracks, mounting holes, bearings, carriage and coupling.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
[Watch the MP4](showcase/hiwin-kk60/modeling.mp4) · [Edit the model](showcase/hiwin-kk60/model.json) · [Read the independent checks](showcase/hiwin-kk60/verification.json) · [Dimensions and assumptions](examples/hiwin-kk60/sources.json)
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
node node_modules/@coloopx/colocad/examples/hiwin-kk60/run.mjs ./actuator
|
|
17
|
+
npx colocad view ./actuator/session
|
|
18
|
+
npx colocad replay ./actuator/session ./actuator.html
|
|
19
|
+
# Optional: Playwright/Chromium + FFmpeg are required for video encoding.
|
|
20
|
+
npx colocad render ./actuator/session ./modeling.mp4
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This is a catalog-based product reconstruction, with explicitly approximated internal races/bearings and no manufacturing certification. The animation reads actual saved CAD revisions; measured call times appear separately from edited playback. It is not a performance comparison. See [CLI history/rendering](docs/modeling-history.md) and the [actual agent modeling workflow](docs/modeling-workflow.zh-CN.md).
|
|
24
|
+
|
|
25
|
+
## How many tendon hands can an agent deliver in 100 seconds?
|
|
26
|
+
|
|
27
|
+
**colocad delivered 44 complete revisions to build123d’s 33 (+33.3%), with 57.1% lower peak sampled sandbox memory.** Both tools rebuilt and assembled the same 43-solid hand at each revision. Each tick marks a complete STEP handed off to storage.
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
The GIF shows the **highest memory sampled so far** for each tool on the same 0–512 MiB scale. For actual usage between builds, see the [instantaneous-memory replay (MP4)](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window-en.mp4) or the [timestamped samples](showcase/tendon-hand/evidence/window-optimized.json).
|
|
32
|
+
|
|
33
|
+
| Same revision queue, 1 vCPU / 512 MiB | Optimized colocad | build123d |
|
|
34
|
+
|---|---:|---:|
|
|
35
|
+
| Complete hands delivered in 100 s | **44** | 33 |
|
|
36
|
+
| First STEP | **2.223 s** | 3.010 s |
|
|
37
|
+
| Median job time on the same first 33 inputs | **2.234 s** | 2.855 s |
|
|
38
|
+
| Highest sampled cgroup memory over the 100 s window | **130.9 MiB** | 304.9 MiB |
|
|
39
|
+
|
|
40
|
+
One measured window per backend, with a new CAD process for each revision. The original run used the alpha.2 SDK and the optimized Linux arm64 kernel now bundled in alpha.3. Memory samples taken about every 25 ms include subprocesses, tmpfs and charged file cache. Every counted STEP reopened successfully. [Measurement method](showcase/tendon-hand/window/README.md) · [Detailed build and single-call replay](showcase/tendon-hand/assembly-performance.md)
|
|
41
|
+
|
|
42
|
+
The static scorecard below uses the **published alpha.2 binary**. With fresh tool processes the sensor rail and manifold reached STEP 22.0× and 12.9× faster than build123d, using 7.7% and 8.0% of its peak memory.
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary>See the static comparison across four workloads</summary>
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
| Deliverable | Time to STEP: colocad / build123d | Speedup¹ | Peak memory: colocad / build123d | Share of build123d peak |
|
|
52
|
+
| :--- | ---: | ---: | ---: | ---: |
|
|
53
|
+
| Sensor rail | 113 / 2,485 ms | **22.0×** | 20.0 / 259.3 MiB | **7.7%** |
|
|
54
|
+
| Port manifold | 230 / 2,963 ms | **12.9×** | 20.7 / 258.7 MiB | **8.0%** |
|
|
55
|
+
| Tendon-hand proximal link | 259 / 2,244 ms | **8.6×** | 21.4 / 260.1 MiB | **8.2%** |
|
|
56
|
+
| Complete 43-solid hand | 3,952 / 3,293 ms | **0.83×** | 52.7 / 271.3 MiB | **19.4%** |
|
|
57
|
+
|
|
58
|
+
¹ build123d time divided by colocad time from unrounded observations. Same Linux arm64 image, 1 vCPU, 512 MiB. Five fresh processes and cgroups per part and backend after warm-up. Time is the median wall clock including startup, imports, modeling, backend checks and STEP export. Memory is the maximum measured cgroup peak; charged pages, temporary outputs and tool descendants count. Installation, container startup, previews, inference and a resident agent are excluded.
|
|
59
|
+
|
|
60
|
+
[Rail/manifold samples](docs/benchmarks/runs.json) · [Finger/hand samples](showcase/tendon-hand/evidence/scope.json) · [Four-view hand study and CAD downloads](showcase/tendon-hand/README.md) · [Offline scorecard](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/time-to-step.html)
|
|
61
|
+
|
|
62
|
+
**Historical alpha.2 result.** in a separate 100-second sweep of complete hand revisions, colocad delivered 24 STEPs to build123d’s 30. Every counted file reopened as a valid 43-solid assembly. [Timestamped outputs and paired geometry checks](showcase/tendon-hand/evidence/window.json)
|
|
63
|
+
|
|
64
|
+
## SDK, CLI or skill?
|
|
65
|
+
|
|
66
|
+
**Start here:** [first part and edit](docs/getting-started.md) · [SDK/API reference](docs/api.md) · [modeling best practices](docs/best-practices.md).
|
|
67
|
+
|
|
68
|
+
| Your harness | Integration guide |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Pi agent core / Pi coding agent | [Typed tool adapter, extension and skill](docs/integrations/pi.md) |
|
|
71
|
+
| Claude Code | [Project skill and local CLI](docs/integrations/claude-code.md) |
|
|
72
|
+
| Codex | [Project skill, invocation and artifact inspection](docs/integrations/codex.md) |
|
|
73
|
+
| Other harnesses | [Sandbox architecture, revision state and artifact lifecycle](docs/integrations/overview.md) |
|
|
74
|
+
|
|
75
|
+
The [runnable examples](examples/integrations/README.md) exercise the published package, real native builds and Pi tool-loop error recovery. See [what was verified](docs/integrations/verification.md) and [how to contribute](CONTRIBUTING.md).
|
|
76
|
+
|
|
77
|
+
Install with `npm install @coloopx/colocad@0.1.0-alpha.3`. This version bundles the optimized assembly kernel and the complete agent skill. The skill lives at `node_modules/@coloopx/colocad/skills/colocad/`. Point your harness at its `SKILL.md` or copy the whole directory into your agent’s skill collection.
|
|
78
|
+
|
|
79
|
+
For a dimensioned part, try “Make a 100 × 50 × 6 mm plate with a centered 3 × 2 grid of Ø6 through-holes on 32 × 30 mm pitches.” The skill includes editable stock, hole grids, sleeves, brackets and open housings. [Quick-build commands and examples](skills/colocad/references/quick-build.md)
|
|
80
|
+
|
|
81
|
+
- **In an application or harness:** call `build(tree, newDir, { preview: true })` in the SDK. Use `CadClient.build(model)` for named multi-solid assemblies.
|
|
82
|
+
- **In a shell or agent tool call:** install `npm install @coloopx/colocad@0.1.0-alpha.3`. Run `./node_modules/.bin/colocad plan tree.json`, then `./node_modules/.bin/colocad build tree.json ./new-part --preview`. Open `new-part/part/model.step`.
|
|
83
|
+
- **From drawings with an agent:** install the [colocad skill](skills/colocad/SKILL.md). Start the next turn with “Use `$colocad` to reconstruct these four views, export STEP, and flag any internal details you inferred.” [Installation and assembly replay](showcase/tendon-hand/README.md#try-it-with-your-agent).
|
|
84
|
+
|
|
85
|
+
## What the two STEP writers produced
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
Each backend modeled the part from the same parameters. The images use the exported STEPs, the same mesher and camera. OCCT reopened each file as **one valid solid**. Both rail exports had 22 faces and 56 edges; both manifold exports had 27 faces and 54 edges. The two directional boolean differences measured **0 mm³** in both cases (boolean tolerance: 0.000001 mm). [Geometry checks](docs/benchmarks/step-checks.json)
|
|
90
|
+
|
|
91
|
+
On the manifold, build123d’s modeling phase alone was **43.8 ms** to colocad’s **53.7 ms**, while build123d import alone took **2.45 s**. The table measures a fresh tool call, not the speed of an isolated boolean operation. [Stage timings and reproduction](benchmarks/readme/README.md)
|
|
92
|
+
|
|
93
|
+
### When the agent only changes the camera
|
|
94
|
+
|
|
95
|
+
The first preview saves a display mesh. For a second view of unchanged geometry, the kernel SDK can load that mesh instead of rebuilding the solid or triangulating it again. Here are five-run medians for the same **top view**, comparing two paths inside colocad:
|
|
96
|
+
|
|
97
|
+
| Part | Rebuild part + render | Render from saved mesh | Speedup |
|
|
98
|
+
| :--- | ---: | ---: | ---: |
|
|
99
|
+
| Sensor rail | 108.8 ms | 19.4 ms | **5.6×** |
|
|
100
|
+
| Port manifold | 223.8 ms | 13.3 ms | **16.8×** |
|
|
101
|
+
|
|
102
|
+
The PNG, GLB and STL from both paths matched byte for byte on every pair. This test starts with the SDK already loaded and includes native process startup and display output. A geometry edit needs a new revision. [Preview measurements and hashes](docs/benchmarks/preview-runs.json)
|
|
103
|
+
|
|
104
|
+
## What ships
|
|
105
|
+
|
|
106
|
+
| In the [npm tarball](https://www.npmjs.com/package/@coloopx/colocad) | In the [source repository](https://github.com/Coloopx/colocad) |
|
|
107
|
+
| :--- | :--- |
|
|
108
|
+
| Agent skill, CLI, JavaScript API, TypeScript declarations and precompiled Rust executables for **Linux x64, Linux arm64 and macOS arm64**. Node.js 22+. | [Rust CAD source](crates/agent-cad/src), [TypeScript kernel SDK](kernel/src), [feature compiler](src/tree.mjs), tests and [pinned SolidCore dependency](third_party/solidcore.lock.json). |
|
|
109
|
+
|
|
110
|
+
For example, on Linux arm64 the CLI launches `node_modules/@coloopx/colocad/kernel/native/linux-arm64/agent-cad`. The tarball contains the executable; the Rust `.rs` files are in the repository.
|
|
111
|
+
|
|
112
|
+
**Alpha status.** Linux supports parametric edits, STEP and PNG/GLB/STL export. Direct generation of a complex, editable SOLIDWORKS part on Linux is still experimental. The optional Windows author compiles against the SOLIDWORKS 2024 interop API; a licensed native rebuild has not been verified. See the [native author](#native-solidworks-author-experimental) and [validation notes](docs/validation.md).
|
|
6
113
|
|
|
7
114
|
## Run the examples
|
|
8
115
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# colocad
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [开发与接入指南](docs/README.zh-CN.md) · [npm 包](https://www.npmjs.com/package/@coloopx/colocad) · [下载单文件对比报告:含四份 STEP](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/comparison.html)
|
|
4
|
+
|
|
5
|
+
让沙箱内的 agent 用 JSON 描述可改参的机械零件,输出 STEP 实体、PNG 预览和 GLB/STL 网格。**npm 包自带编译好的 Rust CAD 内核**:Linux x64、Linux arm64 和 macOS arm64 各一份。agent 和 harness 在同一沙箱里调用 Node CLI 或 TypeScript API,CLI 直接启动本地 Rust 程序。安装后建模不需要网络、Python、Rust 工具链或额外服务。[Rust 源码](crates/agent-cad/src)和[内核依赖版本](third_party/solidcore.lock.json)在本仓库。
|
|
6
|
+
|
|
7
|
+
## 真实工业产品:从厂家图纸到整机及建模动画
|
|
8
|
+
|
|
9
|
+
[HIWIN KK60 执行器实例](examples/hiwin-kk60/README.md)对应真实目录配置:300 mm 导轨、5 mm 导程、210 mm 行程,包含 **52 个原生特征、81 个命名实例、16 个持久化建模阶段**。螺旋槽、安装孔、导轨滚道均为实际 B-rep 几何。
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
[MP4 动画](showcase/hiwin-kk60/modeling.mp4) · [可编辑模型](showcase/hiwin-kk60/model.json) · [独立验证](showcase/hiwin-kk60/verification.json) · [尺寸来源与假设](examples/hiwin-kk60/sources.json)
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
node node_modules/@coloopx/colocad/examples/hiwin-kk60/run.mjs ./actuator
|
|
17
|
+
npx colocad view ./actuator/session
|
|
18
|
+
npx colocad replay ./actuator/session ./actuator.html
|
|
19
|
+
# 视频导出另需 Playwright/Chromium 和 FFmpeg。
|
|
20
|
+
npx colocad render ./actuator/session ./modeling.mp4
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
这是依据厂家目录进行的整机复建,未公开的轴承、滚道与回珠细节有明确近似/缺失标注,不能作为制造认证模型。动画读取实际保存的建模结果,播放节奏与实测构建耗时分开显示,不构成 build123d 性能比较。参见[实际操作流程](docs/modeling-workflow.zh-CN.md)和 [CLI 可视化与导出](docs/modeling-history.md)。
|
|
24
|
+
|
|
25
|
+
## 100 秒能交付多少版绳驱灵巧手?
|
|
26
|
+
|
|
27
|
+
**colocad 交付 44 版,build123d 交付 33 版:交付量多 33.3%,采样峰值内存低 57.1%。** 两边按同一组参数逐版建模、装配。每条刻线代表一份含 43 个实体的整手 STEP 已写入持久存储。
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
动图底部显示两边**从开始到当前时刻采到的最高内存**,共用 0–512 MiB 刻度。要看每次建模之间内存如何回落,可打开[瞬时内存回放(MP4)](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window-zh-CN.mp4)或[原始采样](showcase/tendon-hand/evidence/window-optimized.json)。
|
|
32
|
+
|
|
33
|
+
| 同一改参队列,1 vCPU / 512 MiB | colocad 优化内核 | build123d |
|
|
34
|
+
|---|---:|---:|
|
|
35
|
+
| 100 秒内交付的完整整手 | **44 份** | 33 份 |
|
|
36
|
+
| 首份 STEP | **2.223 s** | 3.010 s |
|
|
37
|
+
| 共同前 33 份交付耗时中位数 | **2.234 s** | 2.855 s |
|
|
38
|
+
| 连续 100 秒内的最高采样内存 | **130.9 MiB** | 304.9 MiB |
|
|
39
|
+
|
|
40
|
+
各运行一个真实窗口,每版新起 CAD 进程。这次原始记录使用 alpha.2 SDK 和优化后的 Linux arm64 内核。alpha.3 已内置同一份二进制。内存约每 25 ms 采样,包含子进程、临时文件和计入本容器的文件缓存。两边计入的 STEP 都已独立回读。[单文件回放与 STEP 下载](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window.html) · [建模细节与单次原速回放](showcase/tendon-hand/assembly-performance.md)
|
|
41
|
+
|
|
42
|
+
以下静态表记录 npm **0.1.0-alpha.2 自带内核**的历史基线。新进程交付导轨和歧管分别快 22.0× 和 12.9×,峰值内存分别为 build123d 的 7.7% 和 8.0%。
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary>查看四种任务的静态对照图</summary>
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
| 独立交付物 | 首份 STEP:colocad / build123d | 交付速度比¹ | 沙箱峰值:colocad / build123d | 内存占对方 |
|
|
52
|
+
|---|---:|---:|---:|---:|
|
|
53
|
+
| 三槽导轨 | 113 / 2,485 ms | **22.0×** | 20.0 / 259.3 MiB | **7.7%** |
|
|
54
|
+
| 四盲孔歧管 | 230 / 2,963 ms | **12.9×** | 20.7 / 258.7 MiB | **8.0%** |
|
|
55
|
+
| 绳驱手近节指骨 | 259 / 2,244 ms | **8.6×** | 21.4 / 260.1 MiB | **8.2%** |
|
|
56
|
+
| 43 实体整手 | 3,952 / 3,293 ms | **0.83×** | 52.7 / 271.3 MiB | **19.4%** |
|
|
57
|
+
|
|
58
|
+
¹ 速度比为 build123d 用时 ÷ colocad 用时,按未取整的读数计算。Linux arm64、1 vCPU、512 MiB。每组预热后交替运行五轮,**耗时取中位数,内存取五轮容器 cgroup 峰值最大值**。计入启动、导入、建模、后端自身的检查及 STEP 导出;不含安装、容器启动、预览、模型推理或常驻 agent。单件和整手使用各自对应的公开接口。
|
|
59
|
+
|
|
60
|
+
[原始读数:导轨与歧管](docs/benchmarks/runs.json) · [原始读数:指骨与整手](showcase/tendon-hand/evidence/scope.json) · [四视图、可编辑整手和 STEP](showcase/tendon-hand/README.md) · [离线数据卡](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/time-to-step.html)
|
|
61
|
+
|
|
62
|
+
**旧版整手基线。** 另一项 100 秒、按顺序改参的实测中,colocad 交付 24 份整手 STEP,build123d 交付 30 份;每份都是完整的 43 个实体,已逐件回读。[两端交付时间戳与几何核对](showcase/tendon-hand/evidence/window.json)
|
|
63
|
+
|
|
64
|
+
## SDK、CLI、skill 怎么选?
|
|
65
|
+
|
|
66
|
+
SDK 是基础,CLI / 工具负责执行,skill 提供建模步骤与常用结构。完整文档从[中文开发指南](docs/README.zh-CN.md)开始,包含模型格式、改参、预览复用、失败处理和产物保存。
|
|
67
|
+
|
|
68
|
+
| 使用环境 | 接入文档 |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Pi agent core / Pi coding agent | [工具适配器、extension 与 skill](docs/integrations/pi.md) |
|
|
71
|
+
| Claude Code | [项目 skill + 本地 CLI](docs/integrations/claude-code.md) |
|
|
72
|
+
| Codex | [skill 安装、调用与产物检查](docs/integrations/codex.md) |
|
|
73
|
+
| 自建 harness | [同沙箱架构、会话状态与产物生命周期](docs/integrations/overview.md) |
|
|
74
|
+
|
|
75
|
+
[可运行示例与接入回归](examples/integrations/README.md) · [建模最佳实践](docs/best-practices.md) · [常见故障](docs/troubleshooting.md) · [贡献指南](CONTRIBUTING.md)
|
|
76
|
+
|
|
77
|
+
运行 `npm install @coloopx/colocad@0.1.0-alpha.3` 即可安装优化后的装配内核和完整 skill。沙箱内的 harness 可加载 `node_modules/@coloopx/colocad/skills/colocad/SKILL.md`,也可以把整个 `colocad` skill 目录复制到 agent 的技能目录。
|
|
78
|
+
|
|
79
|
+
常见机械件可以让 agent 直接按尺寸搭建。例如「做一块 100 × 50 × 6 mm 的安装板,钻 3 × 2 个 Ø6 通孔,两向孔距 32 和 30 mm」。skill 自带可改参的孔阵列、轴套、角码、开口壳和四种基础实体。参见[基础形状与结构的命令示例](skills/colocad/references/quick-build.md)。
|
|
80
|
+
|
|
81
|
+
- **应用或 harness 集成:** 进程里直接调用 SDK 的 `build(tree, newDir, { preview: true })`;多实体装配用 `CadClient.build(model)`。
|
|
82
|
+
- **终端或沙箱 agent:** 安装 `npm install @coloopx/colocad@0.1.0-alpha.3`;用 `./node_modules/.bin/colocad plan tree.json` 检查特征,再用 `./node_modules/.bin/colocad build tree.json ./new-part --preview`。成品在 `new-part/part/model.step`。全程在同一沙箱内。
|
|
83
|
+
- **从多视图交给 agent:** 从 [skills/colocad](skills/colocad/SKILL.md) 安装 skill;下个回合输入「用 `$colocad` 读这四张图,生成可编辑模型和 STEP,并标出推断的内部结构」。[完整安装命令、SDK 装配示例和重放步骤](showcase/tendon-hand/README.md#try-it-with-your-agent)。
|
|
84
|
+
|
|
85
|
+
以 Linux arm64 为例,安装后可执行文件就在 `node_modules/@coloopx/colocad/kernel/native/linux-arm64/agent-cad`。npm 分发编译产物;要读或修改 `.rs` 源文件,请用上面的 GitHub 源码链接。
|
|
86
|
+
|
|
87
|
+
## 两个建模后端做出来的东西一样吗?
|
|
88
|
+
|
|
89
|
+

|
|
90
|
+
|
|
91
|
+
左右两列分别从相同参数独立建模、导出 STEP,再用同一套 OCCT 三角化参数、相机和光照出图。四份 STEP 回读都是有效的单实体。导轨各有 22 个面、56 条边;歧管各有 27 个面、54 条边。两个零件分别做 A−B、B−A,测得差集体积均为 **0 mm³**(布尔容差 0.000001 mm)。[逐件几何核对](docs/benchmarks/step-checks.json)
|
|
92
|
+
|
|
93
|
+
只看歧管几何阶段,build123d 是 43.8 ms,colocad 是 53.7 ms;build123d 导入则用了 2.45 s。端到端提速不能当作纯几何运算提速。[分阶段数据与复现方法](benchmarks/readme/README.md)
|
|
94
|
+
|
|
95
|
+
## 如果 agent 只是转动视角呢?
|
|
96
|
+
|
|
97
|
+
首次预览会保存网格。同一个零件从等轴视图切到俯视图,SDK 可以用 `observeArtifact` 重新出图,跳过精确建模和三角化。同一版 colocad 在同样沙箱预算下得到以下五轮中位数:
|
|
98
|
+
|
|
99
|
+
| 切到俯视图 | 完整重建并出图 | 复用网格出图 | 加速比 |
|
|
100
|
+
| :--- | ---: | ---: | ---: |
|
|
101
|
+
| 导轨 | 108.8 ms | 19.4 ms | **5.6×** |
|
|
102
|
+
| 歧管 | 223.8 ms | 13.3 ms | **16.8×** |
|
|
103
|
+
|
|
104
|
+
每对输出的 PNG、GLB、STL 三个文件均逐字节相同。这一组只比较 colocad 的两条路径;SDK 已加载,计时包括启动本地 Rust 进程和写出显示文件。改几何参数需要生成新版本。[预览耗时和文件哈希](docs/benchmarks/preview-runs.json)
|
|
105
|
+
|
|
106
|
+
## 试跑并改参
|
|
107
|
+
|
|
108
|
+
需要 Node.js 22+。输出目录必须是新目录。
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm install @coloopx/colocad@0.1.0-alpha.3
|
|
112
|
+
npx colocad build node_modules/@coloopx/colocad/examples/manifold.json ./manifold --preview
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
打开 `manifold/part/model.step` 检查实体;`preview.png`、`model.glb` 和 `model.stl` 用于查看。歧管由六边形拉伸、盲孔切除、上缘圆角、引用种子孔的线性阵列和矩形浅槽构成。将 `instances` 从 4 改到 3,少切一个 Ø6 × 8 mm 的盲孔,实测恢复材料 **226.195 mm³**,与圆柱体积一致。[验证记录](docs/evidence/scoped-runner.json)
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
import { readFile } from 'node:fs/promises';
|
|
119
|
+
import { build } from '@coloopx/colocad';
|
|
120
|
+
|
|
121
|
+
const tree = JSON.parse(await readFile('./node_modules/@coloopx/colocad/examples/manifold.json', 'utf8'));
|
|
122
|
+
tree.parameters.instances = 3;
|
|
123
|
+
const result = await build(tree, './three-port-manifold', { preview: true });
|
|
124
|
+
console.log(result.step);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
公开特征接口支持矩形、圆和多边形草图拉伸、切除、按 Z 平面选边的定半径圆角,以及沿 X/Y 的拉伸或切除阵列。[类型定义](src/index.d.mts) · [更底层的内核 API](kernel/src/client.ts)
|
|
128
|
+
|
|
129
|
+
**交付边界:** Linux 已验证 STEP、网格和改参。Linux 直接生成复杂、可在 SOLIDWORKS 里编辑和重建的原生 `.SLDPRT` 尚未完成。仓库中的 Windows 作者程序已针对 SOLIDWORKS 2024 接口编译,尚未在有授权的 SOLIDWORKS 上完成回读重建。[验证说明](docs/validation.md) · [从源码构建](README.md#build-and-verify-from-source)
|
package/bin/colocad.mjs
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { compileTree, build } from "../src/index.mjs";
|
|
3
|
+
import { compileTree, build, kernelModel } from "../src/index.mjs";
|
|
4
|
+
import { ModelingSession, exportSessionHtml } from "../src/session.mjs";
|
|
5
|
+
import { startViewer, parseViewOptions } from "../src/view-server.mjs";
|
|
6
|
+
import { renderSession, parseRenderOptions } from "../src/render.mjs";
|
|
4
7
|
import { writeSolidWorks } from "../src/solidworks.mjs";
|
|
5
8
|
const [cmd, input, output, ...flags] = process.argv.slice(2);
|
|
6
9
|
const help =
|
|
7
|
-
"colocad build TREE.json NEW_DIRECTORY [--preview]\ncolocad plan TREE.json\ncolocad solidworks NATIVE-JOB.json NEW_FILE.SLDPRT";
|
|
10
|
+
"colocad build TREE.json NEW_DIRECTORY [--preview]\ncolocad plan TREE.json\ncolocad record MODEL.json SESSION_DIRECTORY [--label TEXT]\ncolocad replay SESSION_DIRECTORY OUTPUT.html\ncolocad view SESSION_DIRECTORY [--no-open] [--port PORT] [--export OUTPUT.html] [--cutaway] [--view iso|front|side|top]\ncolocad render SESSION_DIRECTORY OUTPUT.mp4|OUTPUT.gif [--width N] [--height N] [--fps N] [--seconds-per-step N]\ncolocad solidworks NATIVE-JOB.json NEW_FILE.SLDPRT";
|
|
8
11
|
try {
|
|
9
12
|
if (cmd === "--help" || cmd === "-h" || !cmd) console.log(help);
|
|
13
|
+
else if (cmd === "render" && input && output) {
|
|
14
|
+
console.log(JSON.stringify(await renderSession(input,output,parseRenderOptions(flags))));
|
|
15
|
+
}
|
|
16
|
+
else if (cmd === "view" && input) {
|
|
17
|
+
const options=parseViewOptions(process.argv.slice(4));
|
|
18
|
+
const viewer=await startViewer(input,options);
|
|
19
|
+
console.log(JSON.stringify({event:'viewer-ready',url:viewer.url,exportedHtml:viewer.exportedHtml}));
|
|
20
|
+
let closing=false;
|
|
21
|
+
const close=async()=>{if(closing)return;closing=true;await viewer.close();process.exitCode=0;};
|
|
22
|
+
process.once('SIGINT',close);process.once('SIGTERM',close);
|
|
23
|
+
}
|
|
24
|
+
else if (cmd === "replay" && input && output && !flags.length) {
|
|
25
|
+
console.log(JSON.stringify(await exportSessionHtml(input, output)));
|
|
26
|
+
}
|
|
10
27
|
else {
|
|
11
|
-
if (!input || !["plan", "build", "solidworks"].includes(cmd))
|
|
28
|
+
if (!input || !["plan", "build", "solidworks", "record"].includes(cmd))
|
|
12
29
|
throw Error(help);
|
|
13
30
|
const raw = await readFile(input);
|
|
14
31
|
if (raw.length > 2 * 1024 * 1024) throw Error("Input exceeds 2 MiB");
|
|
15
32
|
const spec = JSON.parse(raw.toString("utf8"));
|
|
16
33
|
let res;
|
|
17
|
-
if (cmd === "
|
|
34
|
+
if (cmd === "record" && output && (!flags.length || (flags.length===2 && flags[0]==="--label"))) {
|
|
35
|
+
let session;
|
|
36
|
+
try { session=await ModelingSession.create(output,{wallMs:120000}); }
|
|
37
|
+
catch(error) { if(error.code!=="EEXIST") throw error; session=await ModelingSession.open(output,{wallMs:120000}); }
|
|
38
|
+
res=await session.build(spec.format==="colocad/1"?kernelModel(spec):spec,{label:flags[1]??input});
|
|
39
|
+
if(!res.ok) process.exitCode=1;
|
|
40
|
+
}
|
|
41
|
+
else if (cmd === "plan" && !output) res = compileTree(spec);
|
|
18
42
|
else if (
|
|
19
43
|
cmd === "build" &&
|
|
20
44
|
output &&
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Developer documentation
|
|
2
|
+
|
|
3
|
+
[Actual modeling workflow](modeling-workflow.zh-CN.md) · [CLI modeling history and viewer (development)](modeling-history.md)
|
|
4
|
+
|
|
5
|
+
Build locally with **SDK → CLI/tools → skill**. The skill guides modeling decisions; the SDK and Rust kernel execute them. Agent, harness and CAD process share the same sandbox and filesystem.
|
|
6
|
+
|
|
7
|
+
These guides target **@coloopx/colocad 0.1.0-alpha.3**, Node.js 22+, Linux x64/arm64 or macOS arm64. The project is still alpha; documentation does not imply complete CAD coverage.
|
|
8
|
+
|
|
9
|
+
[中文开发指南](README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
| Your task | Start here |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Create a part and edit a dimension | [Getting started](getting-started.md) |
|
|
14
|
+
| Choose the model format and understand editability | [Models and artifacts](concepts.md) |
|
|
15
|
+
| Call the SDK, CLI or tools | [API reference](api.md) |
|
|
16
|
+
| Integrate with an existing sandbox/harness | [Integration architecture](integrations/overview.md) |
|
|
17
|
+
| Register tools in Pi agent core or Pi coding agent | [Pi integration](integrations/pi.md) |
|
|
18
|
+
| Use Claude Code | [Claude Code integration](integrations/claude-code.md) |
|
|
19
|
+
| Use Codex | [Codex integration](integrations/codex.md) |
|
|
20
|
+
| Model efficiently from dimensions or views | [Best practices](best-practices.md) |
|
|
21
|
+
| Diagnose a failed call or installation | [Troubleshooting](troubleshooting.md) |
|
|
22
|
+
| Run examples and contribute a change | [Contributing](../CONTRIBUTING.md) |
|
|
23
|
+
| Understand what has actually been tested | [Integration verification](integrations/verification.md), [geometry validation](validation.md) |
|
|
24
|
+
|
|
25
|
+
Runnable adapters and their regression tests live in [examples/integrations](../examples/integrations/README.md). They install the published npm release. This example project is in GitHub; it is not included in the alpha.3 npm tarball. The skill, assets and its helper scripts **are** included.
|
|
26
|
+
|
|
27
|
+
Performance depends on workload and execution mode. See the [README measurements](../README.md#how-many-tendon-hands-can-an-agent-deliver-in-100-seconds), with their startup, geometry and memory accounting, before choosing a budget. A 512 MiB CAD benchmark is not a 512 MiB guarantee for a resident LLM harness plus CAD.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# 开发与接入指南
|
|
2
|
+
|
|
3
|
+
[实际操作、输入输出与效果提升方法](modeling-workflow.zh-CN.md) · [CLI 查看器与离线导出(开发分支)](modeling-history.md)
|
|
4
|
+
|
|
5
|
+
colocad 的分层是 **SDK 为基础,CLI / 工具负责调用,skill 指导建模流程**。Agent、harness 和 Rust CAD 进程都在同一个沙箱内,共享项目目录。现有 harness 负责模型推理、权限、会话和产物保存,不需要额外部署 CAD 服务。
|
|
6
|
+
|
|
7
|
+
本文对应 `@coloopx/colocad@0.1.0-alpha.3`,要求 Node.js 22+;预编译内核支持 Linux x64/arm64、macOS arm64。工程仍处于 alpha 阶段。
|
|
8
|
+
|
|
9
|
+
## 先跑通一个零件
|
|
10
|
+
|
|
11
|
+
在已有 Node 项目根目录执行;没有 `package.json` 时先运行 `npm init -y`:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install --save-exact @coloopx/colocad@0.1.0-alpha.3
|
|
15
|
+
./node_modules/.bin/colocad build \
|
|
16
|
+
node_modules/@coloopx/colocad/examples/manifold.json ./manifold-v1 --preview
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
查看 `manifold-v1/part/preview.png`,交付 `model.step`,保留 `feature-tree.json` 和 `report.json`。输出目录必须是新目录。这个示例包含拉伸、盲孔切除、圆角和阵列。
|
|
20
|
+
|
|
21
|
+
常用结构可以从 skill 的参数模型开始:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
node node_modules/@coloopx/colocad/skills/colocad/scripts/build.mjs \
|
|
25
|
+
node_modules/@coloopx/colocad/skills/colocad/assets/plate-grid.json \
|
|
26
|
+
./plate-v1 --set length=100 --set xCount=3 --set xPitch=32 --preview
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
命令返回实际 `directory`,其中有 `model.json`、STEP 和预览。这里是 kernel model;上面的歧管是 feature tree。两种格式的入口不同,不能混用。[格式与产物说明](concepts.md) · [完整入门](getting-started.md)
|
|
30
|
+
|
|
31
|
+
## 接入哪个 harness
|
|
32
|
+
|
|
33
|
+
| 环境 | 推荐方式 | 安装位置 / 调用 |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| Codex | 完整 skill + 自带终端和图像工具 | 项目 `.agents/skills/colocad`;`$colocad` |
|
|
36
|
+
| Claude Code | 完整 skill + Bash/Read | 项目 `.claude/skills/colocad`;`/colocad` |
|
|
37
|
+
| Pi coding agent | skill;需要直接工具时加 extension | `.agents/skills/colocad` 或 `--skill`;`/skill:colocad` |
|
|
38
|
+
| Pi agent core / 自建 TS harness | `createCadTools` 适配到现有工具注册机制 | 模型、鉴权、输出目录由现有 harness 提供 |
|
|
39
|
+
|
|
40
|
+
以 Codex 为例,在项目根目录复制完整 skill:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
mkdir -p .agents/skills
|
|
44
|
+
test ! -e .agents/skills/colocad && \
|
|
45
|
+
cp -R node_modules/@coloopx/colocad/skills/colocad .agents/skills/colocad
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
已有 skill 时先检查本地修改,再替换整个目录。Claude Code 将目标目录换为 `.claude/skills/colocad`。不要只复制 `SKILL.md`:脚本、资产和参考文档都需要。
|
|
49
|
+
|
|
50
|
+
可直接给 agent 的任务:
|
|
51
|
+
|
|
52
|
+
> 用 colocad 做一块 100 × 50 × 6 mm 的安装板,中心对称布置 3 × 2 个 Ø6 通孔,两向孔距 32、30 mm。保留可改参 JSON,导出 STEP,检查俯视和等轴视图,说明采用的基准与推断尺寸,返回产物路径。
|
|
53
|
+
|
|
54
|
+
各环境的完整命令和验收方法见 [Codex](integrations/codex.md)、[Claude Code](integrations/claude-code.md)、[Pi core / coding agent](integrations/pi.md)。Pi 示例固定到 1.5.0;不要为了接入 CAD 自动升级已有 harness 的 Pi 依赖。旧版本可先采用 skill + CLI,并对自定义工具适配单独回归。
|
|
55
|
+
|
|
56
|
+
## SDK 接入需要处理的事情
|
|
57
|
+
|
|
58
|
+
实例化 `new CadClient({ outputRoot, wallMs: 30000 })`,按顺序执行 `validate → build/preview → 检查 → 接受版本`。`outputRoot` 由 harness 决定。`createCadTools` 提供 schema 和执行函数;Pi 适配示例将失败回执变成错误工具结果,并将 PNG 作为图像传回模型。
|
|
59
|
+
|
|
60
|
+
每个独立建模会话使用自己的 client 和输出根目录;同一会话顺序执行,便于复用特征检查点和网格。`edit` 不会修改传入的模型对象,接受修改后必须保存新 `model.json` 或合并参数,避免下一次改参回退到旧版本。
|
|
61
|
+
|
|
62
|
+
仅转视角使用缓存预览。观察产物目录可能只有预览;STEP 在 `source_artifact_directory` 指向的几何版本中。沙箱销毁前,用现有 harness 的产物机制保存 JSON、STEP、回执和预览。SDK 没有内置云存储或会话数据库。
|
|
63
|
+
|
|
64
|
+
[架构与生命周期](integrations/overview.md) · [SDK / CLI / 工具 API](api.md) · [可运行示例](../examples/integrations/README.md)
|
|
65
|
+
|
|
66
|
+
## 建模最佳实践
|
|
67
|
+
|
|
68
|
+
- 从控制外形的截面或毛坯开始;板、轴套、角码、壳体优先参考[快速搭建指南](../skills/colocad/references/quick-build.md),按实际图纸改参数和特征。
|
|
69
|
+
- 先确定单位、基准、接口尺寸和未知项;稳定特征 ID,保留每次接受的参数源。四视图看不到的内部结构要明确标注推断。
|
|
70
|
+
- 重复零件只定义一次,用装配实例定位;物理上独立的关节不要随意融合成一个实体。
|
|
71
|
+
- `validate` 通过只代表预检查。验收还要看实体数、边界、体积、孔深和内部区域;重要交付独立回读 STEP。
|
|
72
|
+
- 失败要报告具体特征。不要为了生成图片静默跳过切孔或圆角;显式降级也应保留在交付说明中。
|
|
73
|
+
- 性能分别测冷启动到 STEP、连续改参、缓存预览、包含推理的完整 agent 周期。CAD 的 512 MiB 基准不等于整个 agent/harness 也只需 512 MiB。
|
|
74
|
+
|
|
75
|
+
[详细最佳实践](best-practices.md) · [常见故障](troubleshooting.md) · [贡献与回归](../CONTRIBUTING.md)
|
|
76
|
+
|
|
77
|
+
## 当前验证边界
|
|
78
|
+
|
|
79
|
+
接入示例用已发布 npm 包执行实际 Rust 建模,并经过 Pi core 工具循环、错误恢复、扩展加载和 skill 发现测试。模型回复采用确定性脚本,因此这是接入回归,不是未知图纸上的自主建模成功率测试。Claude Code 尚未做实机推理验收。
|
|
80
|
+
|
|
81
|
+
参数 JSON 可重建,STEP 是精确几何;二者不等于 SOLIDWORKS 原生特征树。Linux 通用可编辑 `.SLDPRT` 尚未完成,Windows author 尚缺授权软件内的完整回读重建验收。[接入验证范围](integrations/verification.md) · [几何与原生输出验证](validation.md)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Modeling history: CLI first
|
|
2
|
+
|
|
3
|
+
Added in alpha.4. In a source checkout, use `node bin/colocad.mjs` in place of `colocad` below. The package entry points are `/session` for the recorder and `/viewer` for the browser component.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
# Build a real milestone and preserve its source, receipt and native preview.
|
|
7
|
+
colocad record model.json ./history --label "Bore the hub"
|
|
8
|
+
|
|
9
|
+
# Repeat record with the next model revision, using the same history directory.
|
|
10
|
+
# Launch the local viewer and open the default browser.
|
|
11
|
+
colocad view ./history
|
|
12
|
+
|
|
13
|
+
# Headless sandbox: print the URL; use the existing harness's port forwarding.
|
|
14
|
+
colocad view ./history --no-open --port 8787
|
|
15
|
+
|
|
16
|
+
# Start a display cutaway and also write a standalone offline file.
|
|
17
|
+
colocad view ./history --cutaway --export ./review.html
|
|
18
|
+
|
|
19
|
+
# Export only: no browser and no listening process.
|
|
20
|
+
colocad replay ./history ./review.html
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`view` binds only to `127.0.0.1`; port 0 (the default) chooses an available port. It prints one JSON ready event with the actual URL. Ctrl+C shuts it down. No native GUI or separately provisioned CAD service is required. It serves a snapshot of the recorded session; rerun the command after adding milestones. `--export` writes the same HTML that the viewer serves. Only the HTML root is served, not an arbitrary directory of files.
|
|
24
|
+
|
|
25
|
+
A session records each actual build/inspection attempt, including failures and interrupted calls. Native artifacts use paths relative to the session. The recorder owns the last successful source so `edit` starts from an accepted model. Archive the whole session directory to preserve all intermediate STEP files. The standalone HTML embeds models, receipts, meshes and previews, plus the final successful geometry STEP.
|
|
26
|
+
|
|
27
|
+
The viewer supports stage selection, review playback, orbit/zoom, four camera presets, display clipping/explosion, part selection/visibility and input/receipt inspection. These display controls do not change exact CAD. Playback is a presentation cadence; measured call durations are shown separately. With no WebGL, native PNG previews provide a fallback.
|
|
28
|
+
|
|
29
|
+
## Export an animation from the CLI
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# Optional media dependencies; not needed for CAD builds or the HTML viewer.
|
|
33
|
+
npm install -D playwright
|
|
34
|
+
npx playwright install chromium
|
|
35
|
+
# Install FFmpeg using your host package manager.
|
|
36
|
+
colocad render ./history ./modeling.mp4 --width 1280 --height 800 --fps 15
|
|
37
|
+
colocad render ./history ./modeling.gif --width 960 --height 600 --fps 10 --seconds-per-step 0.75
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The renderer reads the saved native meshes and starts Chromium and FFmpeg locally. It displays four synchronized cameras, measured call durations and the construction journal. The final segment explodes and reassembles the saved geometry for inspection. It writes the movie, a `.json` manifest (hashes, timings, frames, source revisions) and a `.poster.png`. Existing movies are not overwritten. Encoding does not invoke the CAD kernel. Video duration is edited review pacing and is **not** a performance benchmark. Rendering uses more memory than a geometry-only sandbox; run it where Chromium and FFmpeg are available.
|
|
41
|
+
|
|
42
|
+
[Real catalog product: HIWIN KK60](../examples/hiwin-kk60/README.md) includes the generation and independent STEP verification commands.
|
|
43
|
+
|
|
44
|
+
## SDK integration
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
import { ModelingSession, exportSessionHtml, createSessionTools } from '@coloopx/colocad/session';
|
|
48
|
+
const session = await ModelingSession.create('./history', { title: 'Product reconstruction' });
|
|
49
|
+
const result = await session.build(model, { label: 'Main housing', kind: 'geometry' });
|
|
50
|
+
if (!result.ok) throw new Error(JSON.stringify(result.error));
|
|
51
|
+
await session.edit({ boreDiameter: 8 }, { label: 'Correct bore diameter' });
|
|
52
|
+
await exportSessionHtml(session.root, './review.html');
|
|
53
|
+
const tools = await createSessionTools(session);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Use existing parameters when editing. `createSessionTools` changes `cad_edit` to `{ parameters }`: it uses the recorded accepted source, rather than accepting another model argument. Other modeling calls use their existing arguments. The Pi examples accept `cadSession` or `COLOCAD_SESSION_DIR` to opt into history. See [recorded-pi.mjs](../examples/integrations/recorded-pi.mjs).
|
|
57
|
+
|
|
58
|
+
For embedding into a host UI, `readSessionBundle(directory)` returns the viewer data. Import `@coloopx/colocad/viewer` in the browser, add `<colocad-viewer>`, and assign that data to its `session` property. This is optional host integration; the CLI remains the end-user entry point.
|
|
59
|
+
|
|
60
|
+
[Actual modeling workflow and proposed improvements](modeling-workflow.zh-CN.md) · [Specification and test mapping](../specs/0001-modeling-history.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# HIWIN KK60: a whole industrial actuator reconstructed from its catalog
|
|
2
|
+
|
|
3
|
+
This example models one complete configuration of a real product: **HIWIN KK60 standard, 5 mm screw lead, 300 mm rail, one normal A block, open, without a motor or switches**. It contains 52 native geometric features, 81 named occurrences and 16 recorded construction/assembly milestones. The product is a catalog-based reconstruction, not an OEM manufacturing model.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[MP4](../../showcase/hiwin-kk60/modeling.mp4) · [Editable generated model](../../showcase/hiwin-kk60/model.json) · [Independent verification](../../showcase/hiwin-kk60/verification.json) · [Source dimensions and assumptions](sources.json)
|
|
8
|
+
|
|
9
|
+
## Build, view and export through the CLI
|
|
10
|
+
|
|
11
|
+
From a source checkout with `npm ci` (precompiled native executables must be installed or `npm run build:kernel` run):
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
node examples/hiwin-kk60/run.mjs ./out/hiwin-kk60
|
|
15
|
+
node bin/colocad.mjs view ./out/hiwin-kk60/session
|
|
16
|
+
node bin/colocad.mjs replay ./out/hiwin-kk60/session ./out/hiwin-kk60/review.html
|
|
17
|
+
|
|
18
|
+
# Optional movie tools; CAD and HTML export do not require these.
|
|
19
|
+
npx playwright install chromium
|
|
20
|
+
# Install FFmpeg on the host, then:
|
|
21
|
+
node bin/colocad.mjs render ./out/hiwin-kk60/session ./out/hiwin-kk60/modeling.mp4 \
|
|
22
|
+
--width 1280 --height 800 --fps 15 --seconds-per-step 1.25
|
|
23
|
+
node bin/colocad.mjs render ./out/hiwin-kk60/session ./out/hiwin-kk60/modeling.gif \
|
|
24
|
+
--width 960 --height 600 --fps 10 --seconds-per-step 0.75
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With the npm alpha.4 package, the generator is included under `node_modules/@coloopx/colocad/examples/hiwin-kk60/run.mjs`; the CLI is `npx colocad`. The generator requires a new output directory. It writes the actual per-stage sources/receipts/artifacts to `session/`, plus final `model.json` and `hiwin-kk60.step`. `replay` produces one self-contained HTML file, embedding meshes, source, receipts and final STEP. The interactive viewer supports four viewpoints, cutaway, explosion, part selection and the feature journal. Movie export is optional and runs locally; Chromium/FFmpeg have a separate resource cost from geometry builds.
|
|
28
|
+
|
|
29
|
+
The film shows the real intermediate B-reps: rail stock → guide grooves → six counterbores; saddle → nut seat → mounting pattern; stepped shaft → helical cuts; bearing plate and motor support → assembly. It does not interpolate or simulate machining. The final explode/reassemble segment changes displayed placements only. Recorded call times remain visible; the 26-second review is **not** a 26-second build or a build123d comparison.
|
|
30
|
+
|
|
31
|
+
## How the drawing became CAD in this example
|
|
32
|
+
|
|
33
|
+
The assistant downloaded the [manufacturer's catalog](https://hiwin.com/wp-content/uploads/2026/08/HIWIN-Ballscrew-Driven-Stages-Catalog-1.pdf), read the dimension table with `pdftotext`, rendered PDF page 25 with `pdftoppm`, and inspected enlarged drawing sections. The initial screw-axis interpretation was corrected from 15 to **23 mm** after inspecting SECTION A-A. The catalog was not passed to an automatic colocad image-to-CAD endpoint; no such endpoint is claimed.
|
|
34
|
+
|
|
35
|
+
The assistant then wrote [model.mjs](model.mjs): explicit cross-sections, feature dependencies, cutters and placements. That generator emits the same JSON schema accepted by a harness. `ModelingSession.build` executes each revision in the local Rust kernel. Rendering consumes the resulting saved meshes. This is an observed agent/tool workflow, not evidence that a trained image-to-CAD model reconstructed an arbitrary drawing autonomously.
|
|
36
|
+
|
|
37
|
+
The product's catalog interfaces are the acceptance target: rail length/width, carriage height, hole positions/depths, screw axis, total length and travel. [`sources.json`](sources.json) separates specified numbers, datum interpretations and approximated internals. The one exposed run-time parameter is `travel` (−105…105 mm); its screw rotation is linked at 72 degrees/mm. Other dimensions are explicit source constants or feature values; changing those requires rebuilding and rechecking interfaces. This is not a general KK-series configurator.
|
|
38
|
+
|
|
39
|
+
## Geometric details and verification
|
|
40
|
+
|
|
41
|
+
The screw's 56-turn groove is actual B-rep subtraction: four cubic lofted circular cutters per turn, repeated at 5 mm pitch. It is an approximation to a helical groove, not the proprietary gothic-arch race. The rail, carriage and motor support have real bores, counterbores, tracks, pockets and datum slots. Bolts include hex sockets. Repeated rolling elements share geometry definitions.
|
|
42
|
+
|
|
43
|
+
Run the independent verifier with a development Python environment containing `cadquery-ocp`:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
python examples/hiwin-kk60/verify.py ./out/hiwin-kk60/session ./out/hiwin-kk60/verification.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It reopens every successful STEP in OCCT, checks all solids, counts and volumes, probes the rail counterbores, carriage mounting holes and screw groove/crest, and measures selected rail/carriage overlap at −105/0/+105 mm travel. Tests in `test/kk60.test.mjs` also rebuild both carriage travel endpoints. The recorded result passed all 16 revisions and 64 material probes. Maximum relative volume disagreement was 0.002608%; the three selected rail/carriage overlap volumes were all zero. These checks do not certify every internal fit.
|
|
50
|
+
|
|
51
|
+
Unpublished rolling-element arrangement, bearing sizes, coupling details and nut recirculation are not recovered OEM specifications. The nut is an envelope with a screw bore; recirculation is omitted. Threaded holes are nominal bores; tolerance fits, load rating, fatigue, contact/preload and complete all-pairs interference are not certified. These limits are part of the delivered model, not hidden assumptions.
|
|
52
|
+
|
|
53
|
+
The first full assembly exposed a real library defect: internally generated STEP definitions above 100,000 records were rejected by the assembly writer. Alpha.4 separates the bounded internal export budget (1,000,000 records per definition) from the unchanged external import budget (100,000). A regression test and the full screw assembly cover this fix. The failed original attempt was retained separately during development; it is not counted as a successful build.
|
|
54
|
+
|
|
55
|
+
A complete build with a 640 × 480 preview also passed in a network-disabled Linux arm64 container limited to 1 vCPU and 512 MiB. Native reported total time was 24.192 seconds (one run). Peak memory was not sampled, and no build123d run was performed for this product. [Run evidence](../../showcase/hiwin-kk60/evidence.json).
|