# AutoCAD 從 2D 到 3D

> CAD 3D 建模與繪圖入門：在 AutoCAD 中擠出、按拉與迴轉封閉輪廓，再以聯集與差集，把 2D 圖面變成 3D 實體。免費線上 3D 實體，仍屬部分功能。

在 AutoCAD 中，實體通常從 2D 圖面開始：一個封閉輪廓，像任何平面圖一樣繪製，然後擠出至某個高度或繞軸迴轉，再與其他實體結合，或被其他實體切除。MellowCAD 的 3D 實體也以相同的方式、相同的指令建立。這些功能仍屬部分：目前還沒有掃掠、斷面混成、網面或彩現。每一節都會顯示一段由引擎繪製的過程，其指令歷程就是您會輸入的內容。

## 繪製封閉輪廓

實體需要封閉輪廓：封閉的聚合線、矩形、圓或面域。首尾相接的線仍是各自獨立的物件：`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:
```

## 下一步

- 3D [練習題](https://mellowcad.com/zh-tw/docs/exercises.md)：以面域與一次擠出完成的[安裝板](https://mellowcad.com/zh-tw/docs/exercises/mounting-plate.md)、由剖面迴轉而成的[皮帶輪](https://mellowcad.com/zh-tw/docs/exercises/pulley.md)，以及經聯集與鑽孔完成的[軸承座](https://mellowcad.com/zh-tw/docs/exercises/bearing-block.md)。
- `3DORBIT`（3D 環轉）指令以滑鼠轉動視圖，`VSCURRENT` 則為面加上描影。
