Files
FreeCADWasmDev/web/manual/content/ch03-sketcher.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

132 lines
5.7 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: ch03
order: 3
title: Sketcher 草图
level: core
---
# 第 3 章 Sketcher 草图
## 学习目标
1. 在 XY 平面上新建草图,理解草图是文档里的一个独立对象。
2. 用矩形工具按坐标画出 4 条边,确认几何数量。
3. 认识草图编辑器里的几何、约束、构造线与验证工具。
4. 知道 Web 端草图面板的位置,以及为什么建议用坐标输入而不是鼠标点选。
## 3.1 新建草图
在 Part 工作台打开 `Part → Sketcher → New Sketch`,任务面板询问:
| 参数 | 说明 |
|---|---|
| Name | 草图名称,本例填 `ManualSketch` |
| Support | `Base plane` 或 `Document references` |
| Plane | `XY` / `XZ` / `YZ` |
| Offset | 平面偏移量 |
| Reverse | 反向 |
选 `Base plane`、`XY`、Offset 0,点 OK。
![New Sketch 任务:名称、基准面与偏移](./manual-assets/ch03/sketch-rectangle/01-new-sketch.png)
草图不是“贴着某个面的图形”,它是文档里的独立对象,可以被多个特征引用。
删掉草图,引用它的 Pad 也会失效。
## 3.2 草图编辑器
进入编辑状态后,面板里能看到:
- **Sketch elements**:Edge 1–4、顶点,以及选择 / 隐藏 / 删除操作。
- **Construction geometry**:构造线开关与批量切换。
- **绘图工具**:线、圆、弧、样条、矩形、多边形、槽、圆角、倒角。
- **状态行**:`No drawing operation · N geometries`。
- **Curve mode**:矩形 / 中心矩形 / 长圆等模式。
- **Point 输入**:按 X / Y 坐标精确放置点。
- **Apply sketch tool**:用当前坐标创建曲线。
![草图编辑器:几何列表、绘图工具、坐标输入与预览](./manual-assets/ch03/sketch-rectangle/03-rectangle.png)
> **布局说明**:当前 Web 版把草图编辑器放在右侧属性栏内,面板较窄、需要滚动。
> 这是布局边界,不影响命令与几何数据;桌面版是独立的全屏草图视图。
> 在窄面板里操作时,用坐标输入比鼠标拖拽可靠得多。
## 3.3 用坐标画矩形
1. 点 `Rectangle` 工具,Curve mode 选 `Rectangle`。
2. Point 1 填 `X = 0, Y = 0`。
3. Point 2 填 `X = 60, Y = 40`。
4. 点“Apply sketch tool”。
状态行变成 `4 geometries`,Sketch elements 出现 Edge 1–4,预览区显示 60 × 40 的矩形。
用坐标输入而不是鼠标点选,有三个好处:尺寸精确、可复现、截图清楚。
画草图时先想清楚坐标再动手,比事后加约束修补快得多。
## 3.4 约束与尺寸
几何画出来只是“形状像”,约束才决定它“是不是确定的”。一个完全约束的草图,
所有自由度都被固定,改任何尺寸都只能通过约束值改。
1. 在 Sketch elements 里点选一条边或一个顶点(按住 Shift 可多选)。
2. 打开“Context actions”。
3. 在 Constraint 下拉框选类型:Horizontal、Vertical、Coincident、Distance、Radius 等。
4. 点“Set up constraint”;需要指定点的约束,在 Point 1 / Point 2 下拉框选端点。
5. 状态区显示 `Valid constraints: yes/no`,以及缺失重合点、开放顶点等诊断。
常用约束命令:`Sketcher_ConstrainHorizontal`、`ConstrainVertical`、
`ConstrainCoincidentUnified`、`ConstrainDistance`、`ConstrainRadius`、
`ConstrainEqual`、`ConstrainSymmetric`、`ConstrainBlock`。
![约束空间与诊断入口](./manual-assets/ch03/sketch-rectangle/05-constraint-space.png)
**为什么矩形还要加约束**:矩形工具只保证几何看起来是矩形,四个角是不是真的重合、
边是不是真的水平,要靠 Coincident 与 Horizontal/Vertical 约束来保证。
## 3.5 验证与关闭
- `Sketcher_ValidateSketch`:检查缺失重合、开放顶点、退化几何、反向端点约束。
- `Sketcher_ToggleConstruction`:把选中边转为构造线(不参与成型,只做参考)。
- `Sketcher_Grid` / `Sketcher_Snap`:网格与吸附开关。
- `Sketcher_LeaveSketch` 或“Close sketch”:退出编辑,回到三维视图。
关闭后草图仍留在对象树里,随时双击可以重新编辑。
## 3.6 Sketcher 命令速查
| 组 | 代表命令 |
|---|---|
| 线 / 折线 | `Sketcher_CreateLine`、`CreatePolyline`、`CreateBSpline` |
| 圆 / 弧 | `Sketcher_CreateCircle`、`CreateArc`、`Create3PointArc` |
| 矩形 / 多边形 | `Sketcher_CreateRectangle`、`CreateSquare`、`CreateRegularPolygon` |
| 槽 / 圆角 | `Sketcher_CreateSlot`、`CreateArcSlot`、`CreateFillet`、`CreateChamfer` |
| 约束 | `ConstrainCoincidentUnified`、`ConstrainHorizontal`、`ConstrainVertical`、`ConstrainDistance` |
| 编辑 | `ToggleConstruction`、`Trim`、`Extend`、`Mirror`、`ValidateSketch` |
| 视图 / 吸附 | `Grid`、`Snap`、`SwitchVirtualSpace`、`LeaveSketch` |
完整列表见附录命令索引的 Sketcher 模块。
## 自检
- [ ] 对象树里有 `ManualSketch`。
- [ ] 草图状态行显示 `4 geometries`。
- [ ] Sketch elements 里有 Edge 1–4。
- [ ] 预览区能看到 60 × 40 的矩形。
- [ ] 能退出草图,也能重新进入编辑。
- [ ] 能说出完全约束是什么意思。
## 常见错误
1. 只填一个点就点 Apply,得到零长度几何或直接失败。
2. Point 1 / Point 2 填反,矩形方向相反(尺寸还是对的)。
3. 约束前没选中边或顶点,Constraint 下拉项是灰的。
4. 没关草图就切工作台,任务状态残留,后续操作混乱。
5. 以为画完矩形就完全约束了,实际四个角没约束住。
## 练习
1. 用 Rectangle 再画一个 20 × 20 的方框,观察几何数量从 4 变成 8。
2. 给一条边加 Horizontal 约束,给相邻边加 Vertical 约束。
3. 用 `ValidateSketch` 看缺失重合点数量,再用 Coincident 修复。
4. 把矩形的一条边改成构造线,观察它是否还参与成型。