跳到主要内容

特征、布尔与变换

特征方法在输入 Shape 所属 Session 中创建新 Shape,不修改源 Handle。

轮廓特征

方法核心参数契约
extrude(profile, x, y, z)非零向量线性扫掠 Face 或 Wire
revolve(profile, degrees=360, axis=(0,0,1), origin=(0,0,0))角度、非零轴绕轴旋转轮廓
loft(profiles, solid=True, ruled=False)有序轮廓序列按顺序连接截面
sweep(profile, path, solid=True, frenet=False)轮廓与路径沿曲线携带轮廓
twisted_sweep(profile, distance, twist_degrees, ...)轴向距离与扭转角组合平移与受控旋转

当轮廓与路径允许时,solid=True 请求封闭 Solid;ruled=True 在线性方式连接 Loft 截面;frenet=True 改变扫掠 Frame 行为,并可能使轮廓沿弯曲路径旋转。

布尔

union(left, right)cut(body, tool)intersect(left, right) 要求输入来自相同 Session。返回拓扑可能与任一输入显著不同;布尔后不要继续使用旧 Face 或 Edge 索引。

with cad.Model() as model:
body = model.box(60, 40, 8)
hole = model.translate(model.cylinder(4, 12), 30, 20, -2)
drilled = model.cut(body, hole)
assert drilled.validate().ok

相切、重合、近似相切或极小特征对数值较敏感。特征尺度应明显大于建模公差,并检查结果拓扑。

Edge 与 Face 特征

fillet(shape, radius, edge_indices=None, *, edges=None)chamfer(shape, distance, edge_indices=None, *, edges=None) 接受确定性零基 Edge 索引。推荐使用 edges 关键字,edge_indices 用于调用兼容。不提供选择时,按原生方法的全边行为处理。

shell(shape, thickness, face_indices=None, *, tolerance=1e-3, faces=None) 移除或偏置指定 Face 以形成壁厚。正负厚度方向取决于 Shape 朝向;完成后应验证 Volume、BBox 与开放边界。

缝合

sew(faces, tolerance=1e-6) 把边界兼容的 Face 连接为 Shell。shell_to_solid(shell) 要求 Shell 封闭且朝向一致。缝合成功不等于一定能构成 Solid;排查转换失败时先检查 free_boundaries()

变换

方法解释
translate(shape, x, y, z)按世界坐标位移复制
rotate(shape, degrees, axis, origin)按右手规则、以度为单位旋转复制
mirror(shape, normal, origin)关于给定平面镜像复制
scale(shape, factor, center)关于指定点均匀缩放复制

轴和法向不得为零。Scale Factor 必须满足原生操作要求,不应假定零或负值仍能保持 Solid 朝向与有效性。

局部坐标应先通过 Workplane 转换。全部公共函数与兼容变体见建模符号目录