# AutoCAD 从二维到三维

> CAD 三维入门：将闭合轮廓拉伸、按住并拖动、旋转，再做并集和差集，把二维图形变成三维实体。在线免费的三维实体，目前仅部分支持。

在 AutoCAD 中，实体通常从二维图形开始：一个闭合轮廓，像任何平面图一样画出，然后拉伸到一定高度或绕轴旋转，再与其他实体合并，或被其他实体切除。MellowCAD 的三维实体也用同样的方法、同样的命令创建。三维功能目前仅部分支持：还没有扫掠、放样、网格和渲染。每一节都展示由引擎绘制的操作过程，以及按输入方式记录的命令历史记录。

## 绘制闭合轮廓

实体需要闭合轮廓：闭合多段线、矩形、圆或面域。首尾相连的直线仍然是各自独立的对象：`JOIN`（合并）命令把它们合并为一条多段线，`REGION`（面域）命令则把它们变成面域。请在平面视图中绘制轮廓，在那里输入点最方便。

## 拉伸

`EXTRUDE`（拉伸）命令：选择轮廓，按 Enter 键，然后输入高度。从上方看，实体与其轮廓完全一样：用 `VIEW`（视图管理器）命令或 ViewCube 转动视图来查看它，并用 `VSCURRENT`（视觉样式）命令选择它的显示方式。

由一条闭合多段线构成的 L 形轮廓，拉伸 30，从东南方向观察。

```text
Command: PLINE
Specify start point: 0,0
Current line-width is 0.00
Specify next point or [Arc/Halfwidth/Length/Undo/Width]: @80,0
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: @0,15
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: @-60,0
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: @0,45
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: @-20,0
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: C
Command: EXTRUDE
Current wire frame density:  ISOLINES=4, Closed profiles creation mode = Solid
Select objects to extrude or [MOde]: 1 found
Select objects to extrude or [MOde]:
Specify height of extrusion or [Direction/Path/Taper angle/Expression]: 30
Command: -VIEW
Enter an option [Orthographic]: SEI
Regenerating model.
Command: VSCURRENT
Enter an option [2dwireframe/Hidden/Conceptual] <2dwireframe>: H
Command: ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or [All/Extents/Previous/Scale/Window/Object]: E
Command: ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or [All/Extents/Previous/Scale/Window/Object]: 0.8x
```

## 按住并拖动区域

`PRESSPULL`（按住并拖动）命令不需要轮廓：在任意闭合区域内单击，即使该区域由各自独立的直线围成也可以，然后输入高度。在实体的面上单击时，它会推入或拉出该面。

一个闭合区域，从内部按住并拖动后变成实体。

```text
Command: PRESSPULL
Select object or bounded area:
2 loops extracted.
1 Regions created.
Specify extrusion height or [Multiple]: -8
1 extrusion(s) created
Select object or bounded area:
Command: -VIEW
Enter an option [Orthographic]: SEI
Command: ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or [All/Extents/Previous/Scale/Window/Object]: 0.8x
```

## 旋转

`REVOLVE`（旋转）命令使轮廓绕轴旋转：选择轮廓，用两点、对象或 X、Y、Z 轴指定旋转轴，然后指定角度，默认旋转一整圈。

绕 Y 轴旋转的半剖面。

```text
Command: REVOLVE
Current wire frame density:  ISOLINES=4, Closed profiles creation mode = Solid
Select objects to revolve or [MOde]: 1 found
Select objects to revolve or [MOde]:
Specify axis start point or define axis by [Object/X/Y/Z] <Object>: Y
Specify angle of revolution or [STart angle/Reverse/EXpression] <360>:
Command: -VIEW
Enter an option [Orthographic]: SEI
Command: ZOOM
Specify corner of window, enter a scale factor (nX or nXP), or [All/Extents/Previous/Scale/Window/Object]: 0.8x
```

## 实体的并集与差集

`UNION`（并集）命令把多个实体合并为一个，`SUBTRACT`（差集）命令从一个实体中减去一个或多个实体，`INTERSECT`（交集）命令保留它们的公共部分。孔就是从所穿过的实体中减去的圆柱体。

从长方体中减去圆柱体：一个贯穿的孔。

```text
Command: SUBTRACT
Select solids, surfaces, and regions to subtract from ..
Select objects: 1 found
Select objects:
Select solids, surfaces, and regions to subtract ..
Select objects: 1 found
Select objects:
```

## 下一步

- 三维[练习](https://mellowcad.com/zh-cn/docs/exercises.md)：由面域和一次拉伸做成的[安装板](https://mellowcad.com/zh-cn/docs/exercises/mounting-plate.md)、由剖面旋转而成的[带轮](https://mellowcad.com/zh-cn/docs/exercises/pulley.md)，以及经过并集和钻孔的[轴承座](https://mellowcad.com/zh-cn/docs/exercises/bearing-block.md)。
- `3DORBIT`（三维动态观察）命令用鼠标转动视图，`VSCURRENT` 为各个面着色。
