# 相交和修剪

目前，许多示例都关注从较少维的对象构造较多维的几何体。相交方法允许此较高维度的几何图形生成较低维度的对象，而“修剪”和“选择修剪”命令允许脚本在创建几何形状后对其进行大量修改。

*Intersect* 方法在 Dynamo 中的所有几何图形上定义，这意味着理论上，任何几何图形都可以与任何其他几何图形相交。通常，由于结果对象将始终是输入点本身，因此某些交点没有意义（例如涉及点的交点）。下图概述了对象之间可能存在的交点组合。下图概述了各种相交操作的结果：

### **交集**

| *其中：*  | 曲面 | 曲线 | 平面   | 实体 |
| ------ | -- | -- | ---- | -- |
| **曲面** | 曲线 | 点  | 点，曲线 | 曲面 |
| **曲线** | 点  | 点  | 点    | 曲线 |
| **平面** | 曲线 | 点  | 曲线   | 曲线 |
| **实体** | 曲面 | 曲线 | 曲线   | 实体 |

下面非常简单的示例演示了平面与 NurbsSurface 的交集。该交集会生成 NurbsCurve 数组，可像使用任何其他 NurbsCurve 一样使用。

```js
// python_points_5 is a set of Points generated with
// a Python script found in Chapter 12, Section 10

surf = NurbsSurface.ByPoints(python_points_5, 3, 3);

WCS = CoordinateSystem.Identity();

pl = Plane.ByOriginNormal(WCS.Origin.Translate(0, 0,
    0.5), WCS.ZAxis);

// intersect surface, generating three closed curves
crvs = surf.Intersect(pl);

crvs_moved = crvs.Translate(0, 0, 10);
```

*Trim* 方法与“Intersect”方法非常相似，因为它几乎为每个几何图形都定义了该方法。但是，与 *Intersect* 相比，*Trim* 存在更多限制。

### **修剪**

|         | *使用：* 点 | 曲线 | 平面 | 曲面 | 实体 |
| ------- | ------- | -- | -- | -- | -- |
| *开：* 曲线 | 是       | 否  | 否  | 否  | 否  |
| 多边形     | -       | 否  | 是  | 否  | 否  |
| 曲面      | -       | 是  | 是  | 是  | 是  |
| 实体      | -       | -  | 是  | 是  | 是  |

关于 *Trim* 方法需要注意的是，需要“选择”点、确定要丢弃哪些几何图形的点以及要保留哪些部分。Dynamo 会查找并放弃与选择点最近的已修剪几何图形。

```js
// python_points_5 is a set of Points generated with
// a Python script found in Chapter 12, Section 10

surf = NurbsSurface.ByPoints(python_points_5, 3, 3);

tool_pts = Point.ByCoordinates((-10..20..10)<1>,
    (-10..20..10)<2>, 1);

tool = NurbsSurface.ByPoints(tool_pts);

pick_point = Point.ByCoordinates(8, 1, 3);

result = surf.Trim(tool, pick_point);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://primer2.dynamobim.org/zh-cn/8_coding_in_dynamo/8-2_geometry-with-design-script/8-intersection-and-trim.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
