Files
make-cad/docs/api/make_polyline_rwire.md
T
倪旌哲 e907fa88a4 Add Vertex and Wire classes documentation; implement auto documentation generation script
- Created `vertex.md` and `wire.md` to document the Vertex and Wire classes in the SimpleCAD API, detailing their attributes, methods, and usage examples.
- Introduced `auto_docs_gen.py` script to automate the extraction of API information from `operations.py` and generate markdown documentation.
- Updated `operations.py` to correct a comment regarding the target normal vector in the `helical_sweep_rsolid` function.
2025-07-06 23:24:31 +08:00

1.3 KiB

make_polyline_rwire

API定义

def make_polyline_rwire(points: List[Tuple[float, float, float]], closed: bool = False) -> Wire

API作用

创建由多个直线段连接的多段线,用于构建折线、多边形轮廓等。 相邻点之间用直线连接,可以创建开放或闭合的多段线。

API参数说明

points

  • 类型: List[Tuple[float, float, float]]
  • 说明: 顶点坐标列表 [(x, y, z), ...], 至少需要2个点,相邻点之间用直线连接

closed

  • 类型: bool, optional
  • 说明: 是否创建闭合的多段线,默认为False。 如果为True,会自动连接最后一个点和第一个点

返回值

Wire: 创建的线对象,由多个直线段组成的多段线

异常

  • ValueError: 当顶点少于2个时抛出异常

API使用例子

>>> # 创建L形多段线
>>> points = [(0, 0, 0), (3, 0, 0), (3, 2, 0)]
>>> l_shape = make_polyline_rwire(points)

>>> # 创建三角形轮廓
>>> triangle_points = [(0, 0, 0), (2, 0, 0), (1, 2, 0)]
>>> triangle = make_polyline_rwire(triangle_points, closed=True)

>>> # 创建复杂的多边形
>>> polygon_points = [(0, 0, 0), (2, 0, 0), (3, 1, 0), (2, 2, 0), (0, 2, 0)]
>>> polygon = make_polyline_rwire(polygon_points, closed=True)