修改了一些之前增加功能的bug
This commit is contained in:
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import math
|
||||
from typing import Any, Iterable
|
||||
|
||||
from build123d import Axis, Compound, Edge, Face, Helix, Location, Plane, ShapeList, Solid, Vector, Wire, export_step
|
||||
from build123d import Axis, Compound, Edge, Face, Location, Plane, ShapeList, Solid, Vector, Wire, export_step
|
||||
|
||||
from .parametric_thread import build_thread_solid
|
||||
from .runtime_types import AxisSpec, HoleSpec, PlaneSpec, ThreadSpec, TopologyRecord, Vector3, canonical_plane_signature
|
||||
@@ -163,8 +163,11 @@ class Build123dGeometryAdapter:
|
||||
return None
|
||||
if len(members) == 1:
|
||||
return members[0]
|
||||
# build123d 类型桩未声明 make_compound,但运行时存在(宽泛类型桩噪音)。
|
||||
return Compound.make_compound(members) # pyright: ignore[reportAttributeAccessIssue]
|
||||
# build123d 0.11 的有效运行时合并 API 是 Compound.make_composite(多体域
|
||||
# 合并为 Compound/Part);Compound.make_compound 在类型桩与运行时均不存在,
|
||||
# 此前的调用在多成员 ShapeList 下会 AttributeError。类型桩未声明
|
||||
# make_composite,保留宽泛类型桩噪音抑制。
|
||||
return Compound.make_composite(members)
|
||||
|
||||
@staticmethod
|
||||
def extrude(face: Face, direction: Vector3) -> Solid:
|
||||
@@ -438,9 +441,27 @@ class Build123dGeometryAdapter:
|
||||
return body.chamfer(distance_mm, distance_2_mm, list(edges), face=face)
|
||||
|
||||
@staticmethod
|
||||
def sweep(section: Face, spine: Edge | Wire) -> Solid:
|
||||
def sweep(
|
||||
section: Face | Wire,
|
||||
spine: Edge | Wire,
|
||||
*,
|
||||
inner_wires: list[Wire] | None = None,
|
||||
make_solid: bool = True,
|
||||
is_frenet: bool = False,
|
||||
transition: Any = None,
|
||||
) -> Solid:
|
||||
# 沿路径线扫掠截面生成实体(build123d 原生扫掠,路径可为直线/曲线/螺旋边)。
|
||||
return Solid.sweep(section, spine)
|
||||
# 默认值对齐 build123d Solid.sweep:make_solid=True 封盖成体;is_frenet=True
|
||||
# 使截面沿路径 Frenet 标架取向保持恒定(螺纹/花键"键侧平行"所需);
|
||||
# transition 为 None 时交给 build123d 默认的 Transition.TRANSFORMED。
|
||||
sweep_options: dict[str, Any] = {
|
||||
"inner_wires": inner_wires,
|
||||
"make_solid": make_solid,
|
||||
"is_frenet": is_frenet,
|
||||
}
|
||||
if transition is not None:
|
||||
sweep_options["transition"] = transition
|
||||
return Solid.sweep(section, spine, **sweep_options)
|
||||
|
||||
@staticmethod
|
||||
def sweep_path(points: Iterable[Vector3]) -> Wire:
|
||||
@@ -451,15 +472,32 @@ class Build123dGeometryAdapter:
|
||||
return Wire([Edge.make_line(vertices[index], vertices[index + 1]) for index in range(len(vertices) - 1)])
|
||||
|
||||
@staticmethod
|
||||
def helix_path(radius_mm: float, pitch_mm: float, turns: float, *, lefthand: bool = False) -> Edge:
|
||||
def helix_path(
|
||||
radius_mm: float,
|
||||
pitch_mm: float,
|
||||
turns: float | None = None,
|
||||
*,
|
||||
height_mm: float | None = None,
|
||||
lefthand: bool = False,
|
||||
) -> Edge:
|
||||
# 构造螺旋线路径(单段 Edge),供扫掠/后续螺纹、斜齿等特征使用。
|
||||
# 螺旋从 (radius, 0, 0) 处沿 +Z 方向上升(lefthand=True 时反向缠绕)。
|
||||
# turns(圈数)与 height_mm(轴向总高)二选一驱动:按圈适配斜齿/花键,
|
||||
# 按高度适配 parametric_thread(length + 两端余量)。构造与 parametric_thread
|
||||
# 原 Edge.make_helix 同源,保证生成器复用后逐位一致。
|
||||
if pitch_mm <= 0:
|
||||
raise ValueError("helix pitch must be positive")
|
||||
if turns <= 0:
|
||||
raise ValueError("helix turns must be positive")
|
||||
helix = Helix(pitch=pitch_mm, height=turns * pitch_mm, radius=radius_mm, lefthand=lefthand)
|
||||
return helix.edges()[0]
|
||||
if (turns is None) == (height_mm is None):
|
||||
raise ValueError("helix_path needs exactly one of turns or height_mm")
|
||||
if turns is not None:
|
||||
if turns <= 0:
|
||||
raise ValueError("helix turns must be positive")
|
||||
height = turns * pitch_mm
|
||||
else:
|
||||
if height_mm <= 0:
|
||||
raise ValueError("helix height must be positive")
|
||||
height = height_mm
|
||||
return Edge.make_helix(pitch=pitch_mm, height=height, radius=radius_mm, lefthand=lefthand)
|
||||
|
||||
@staticmethod
|
||||
def pattern_linear(body: Any, count: int, direction: Vector3, spacing_mm: float) -> Any:
|
||||
|
||||
Reference in New Issue
Block a user