Files
FreeCADWasmDev/web/manual/content/ch10-cam.md
wangdequan 7d9cf3a5ea Rewrite the beginner manual against measured Web behaviour
The manual claimed 32 modules and taught several workflows that do not
run in the web port. Rewrite the chapter bodies and drive every new
screenshot from a real interaction with a waitFor before each shot.

Screenshots go from 33 to 63. ch06-ch13 grow from one page snapshot each
to 3-7 shots taken in headed Chrome, all with empty pageErrors and
consoleErrors and every PNG well above the 5 KB bar.

Correct the text where the port differs from the desktop:

- ch08: Mesh_FromPartShape has no task panel, so the main line becomes
  Mesh_BuildRegularSolid, which really returns typeId Mesh::Cube.
- ch09: no BIM creation command has a panel; only Library, Setup,
  Material and Views are usable.
- ch10: CAM_Job offers only None in its Model select and fails with
  cam_command_failed.
- ch11: the recorded error was Document does not exist; the real one is
  invalid_request: Select source objects in the current document, and
  PageDefault cannot create a page at all.
- ch12: FEM_Analysis has no panel, so the chain breaks at step one.
- ch13: drop every OpenSCAD scene action and screenshot; Robot jog
  buttons, the Plot canvas and Draft viewport picking do not work, so
  the chapter documents the panels instead of pretending they run.

Rebuild gives 15 chapters, 1575 command rows, 1721 search entries and
945197 bytes; check:manual passes both viewports with no errors, no
broken images and no horizontal overflow.

The gap ledger goes from 7 to 11 boundaries. Remove b-openscad-recompile,
which should not exist while the workbench is removed, and record the
five newly measured ones: BIM creation, Mesh_FromPartShape, Draft
viewport picking, Robot without a model and Plot without a canvas.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-15 16:47:14 +08:00

116 lines
5.0 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 任务面板实际暴露的为准,附录里标为边界的不要当通过项。
## 边界与注意
- 没有毛坯或模型时建 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,重新仿真并比较路径条数变化。