Files
FreeCADWasmDev/web/manual/content/ch10-cam.md
wangdequan 300c8efb01 docs(web): full UI surface inventory, illustrated manual, panel screenshots
Interface design document and manual now share one authoritative surface
inventory (333 surfaces across 9 categories, gap 0), and every chapter carries
real Playwright screenshots of the panels it documents.

- tools/fcweb: ui-surface-scan/ui-surface-inventory (deterministic --check),
  build-ui-doc renders panel catalog, workbench matrix and mapping tables;
  blank toolbar crops (<1 KB) are skipped and pruned instead of embedded
- web/tools/manual: generate-panel-index (ch16), audit-ui-gaps,
  generate-final-status, generate-gaps-doc; pager is per-chapter so the manual
  no longer overflows horizontally
- manual: 130 screenshot references / 128 PNGs, panel sections for ch02-ch13
- web/src: utility menus stop click propagation (menu reopened on item click);
  workbench shell gains an OPFS document picker so workbench.html can bind a
  real document instead of the fixed workbench-document id; Sketcher panel
  moves from the command column to the main stage

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 01:30:31 +08:00

159 lines
7.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: ch10
order: 10
title: CAM 加工
level: specialist
---
# 第 10 章 CAM 加工
## 能力概览
CAM 把三维模型变成机床能执行的刀路(G-code)。核心是同一条链路:
**Job(模型 + 毛坯 + 刀具 + 后处理)→ 操作(Profile / Pocket / Drilling)→ 仿真 → Post**。
| 阶段 | 命令 |
|---|---|
| 建 Job | `CAM_Job`(Model、Stock、Tool、Post) |
| 2D / 3D 路径 | `CAM_Profile`、`CAM_Pocket_Shape`、`CAM_Helix`、`CAM_MillFacing` |
| 孔与槽 | `CAM_Drilling`、`CAM_Engrave` |
| 修饰 | `CAM_DressupDogbone`、`DressupDragKnife`、`DressupRampEntry`、`DressupTag` |
| 后处理与仿真 | `CAM_Post`、`CAM_PostSelected`、`CAM_Simulator` |
| 刀具 | `CAM_ToolBitLoad`、`CAM_ToolBitSave`、`CAM_ExportTemplate` |
![CAM Job 任务:Stock、Tool、Model 与 Post](./manual-assets/ch10/cam-job/01-cam-job.png)
## 10.1 建立 CAM Job
先看 `CAM_Job` 面板的实际样子:分组标题是 `Create CAM Job`,里面是作业名、Model、
Stock 与 Post 几个字段。
![CAM_Job:Create CAM Job 面板,含 Model / Stock / Post 字段](./manual-assets/ch10/cam-job/01-cam-job.png)
**实测边界**:Model 下拉里只有 `None` 一项,选不到任何实体。点提交返回
`cam_command_failed: The selected CAM document does not exist`——
CAM 作业需要挂在一个 CAM 文档上,而壳层页面既不创建也不打开文档。
所以下面这条链路在 Web 端只能看面板,不能真正建出 Job。
桌面版标准顺序:
1. 打开 `workbench.html?module=CAM&command=CAM_Job`。
2. 在任务面板选 **Model**(要加工的实体)、**Stock**(毛坯尺寸,可以自动外包)。
3. 选 **Tool**(刀具),刀具直径决定路径间距与过切风险。
4. 选 **Post**(后处理器,例如 GRBL、LinuxCNC),也可加载自定义 post。
5. 点 Create,对象树出现 `Job` 节点,后续操作都挂在它下面。
毛坯尺寸建议直接用“自动外包模型”再留 1–2 mm 余量,手填容易算错基准面。
## 10.2 生成刀路
三个主要操作都有面板,参数结构与桌面一致:
`CAM_Profile`(外形铣)——选轮廓几何、填步距与下刀量:
![CAM_Profile:外形铣操作面板](./manual-assets/ch10/cam-job/02-cam-profile.png)
`CAM_Pocket_Shape`(型腔铣)——多出型腔专用的分层与残料参数:
![CAM_Pocket_Shape:型腔铣操作面板](./manual-assets/ch10/cam-job/03-cam-pocket.png)
`CAM_Post`(后处理)——选后处理器并输出 G-code:
![CAM_Post:后处理器选择与输出](./manual-assets/ch10/cam-job/04-cam-post.png)
这三个面板都会因为缺少 CAM 文档而返回 `Select source objects in the current document`
一类的错误,因此只作结构参考。
桌面版操作顺序:
1. 先选中 Job 节点。
2. 依次添加操作:外形用 `CAM_Profile`,型腔用 `CAM_Pocket_Shape`,钻孔用 `CAM_Drilling`。
3. 每个操作都要选几何(面 / 边 / 孔)并填参数:步距、下刀量、退刀高度、主轴转速。
4. 用 `CAM_Simulator` 走一遍,检查空切、过切与撞刀。
5. `CAM_Post` 输出 G-code,文件写到 OPFS。
**参数之间有关联**:步距大于刀具直径会留下残料,下刀量过大会让模拟里出现红区。
每次改参数后都要重新仿真,不要只看第一遍的结果。
## 10.3 当前 Web 边界
CAM 模块页上有若干 native handler,但**不是全部桌面能力都可用**:
- `Adaptive`、`Surface`、`Waterline` 路径依赖 **OpenCAMLib** 与完整 ToolBit / G-code 栈,
当前 WASM 包未提供,属于边界。
- 完整刀具库(ToolBit 的图形化编辑)与 G-code 编辑器仍是桌面能力。
- Web 端可用命令以 CAM 任务面板实际暴露的为准,附录里标为边界的不要当通过项。
## CAM 任务面板与工具栏
CAM 在 Web 端由两个任务面板配合四组工具栏完成加工流程:
| 表面 | 用途 |
|---|---|
| CAM 桌面任务面板(`cam-desktop-task`) | 作业(Job)与操作的通用参数页,标题随命令变化 |
| CAM 教学教练 · 三轴铣削(`cam-teaching-task`) | 分步引导:选毛坯、选刀具、选操作、生成刀路 |
| Project Setup 工具栏 | 新建 Job、编辑毛坯与装夹 |
| Tool Commands 工具栏 | 刀具库、刀具控制器、探针 |
| New Operations 工具栏 | 轮廓、型腔、钻孔、面铣等操作 |
| Path Modification 工具栏 | 复制、阵列、镜像、延伸与重排刀路 |
操作参数页里的「生成」只重算当前操作;整个 Job 的刀路要用 Job 面板的「重新计算」。刀路计算依赖内核侧的 `area` 与 `tsp_solver` 扩展,导入失败时优先查看 Bottom dock 的 Python console 输出。完整 11 项表面见第 16 章。
### 五个 CAM 面板实拍
CAM 的命令页统一走 `workbench.html?module=CAM&command=<命令>`,面板标题就是命令名。逐页看结构:
`CAM_Job` 是作业入口,`Create CAM Job` 字段区负责命名与选择模型。**实测边界**:Model 下拉里只有 `None`,
没有可选的现有模型;直接提交会返回 `cam_command_failed: The selected CAM document does not exist`:
![CAM_Job:Create CAM Job 字段区,Model 下拉只有 None](./manual-assets/ch10/cam-task-panels/01-cam-job.png)
`CAM_Profile` 是轮廓加工的参数页,字段区标题 `CAM_Profile`,定义要切的轮廓与刀具:
![CAM_Profile:轮廓加工参数页](./manual-assets/ch10/cam-task-panels/02-cam-profile.png)
`CAM_Pocket_Shape` 是型腔加工参数页,字段区标题 `CAM_Pocket_Shape`:
![CAM_Pocket_Shape:型腔加工参数页](./manual-assets/ch10/cam-task-panels/03-cam-pocket.png)
`CAM_Post` 是后处理页,选择后处理器并把刀路输出为 G-code:
![CAM_Post:后处理参数页](./manual-assets/ch10/cam-task-panels/04-cam-post.png)
`CAM simulation` 是刀路仿真页,用于回放刀路轨迹:
![CAM simulation:刀路仿真页](./manual-assets/ch10/cam-task-panels/05-cam-simulator.png)
这五页覆盖了 CAM 的主要命令形态,但在 Web 端缺一个可用的 CAM 文档时,它们都停在「参数可填、结果不可得」的状态。
判断标准很简单:Model 下拉为空说明前置文档没进 CAM 上下文,此时任何提交都只会得到 `cam_command_failed`。
## 边界与注意
- 没有毛坯或模型时建 Job 会失败——Job 需要两者才能算出加工范围。
- 刀具直径填错是最常见的过切原因,改刀后一定重新仿真。
- 后处理器选错,G-code 语法机床不认,表现为机床报解析错误而不是路径错误。
- G-code 落在 OPFS,要交给机床得先“下载到本地”。
## 自检
- [ ] 能创建 CAM Job 并正确选择 Model、Stock、Tool、Post。
- [ ] 能添加 Profile 或 Pocket 操作并设定参数。
- [ ] 能打开 Simulator 检查刀路。
- [ ] 能把 G-code Post 出来,并在 OPFS 找到文件。
- [ ] 能说出 OpenCAMLib 相关命令为什么不列为可用。
## 常见错误
1. 没选毛坯或模型就建 Job。
2. 刀具直径与几何不匹配,路径过切或漏加工。
3. 后处理器选错,机床报语法错误。
4. 把 Adaptive 当成已可用——当前 Web 端受限。
5. 改完参数不重新仿真,直接 Post,把旧刀路发给机床。
## 练习
1. 对 80×60×20 的 Box 建 Job,做一次外形 Profile 加工。
2. 加一个 Drilling 操作,选 4 个孔位,填写正确的钻深与退刀高度。
3. Post 出 G-code,打开文件检查 G0 / G1 与主轴启停指令。
4. 把刀具直径从 6 mm 改成 3 mm,重新仿真并比较路径条数变化。