优化生成流程

This commit is contained in:
2026-08-25 17:41:24 +08:00
parent 51575161dc
commit beaa5dd9fe
50 changed files with 4204 additions and 4261 deletions
@@ -5,7 +5,7 @@ from __future__ import annotations
import math
from typing import Any, Iterable
from build123d import Axis, Edge, Face, Plane, Solid, Vector, Wire, export_step
from build123d import Axis, Compound, Edge, Face, Plane, Solid, Vector, Wire, export_step
from .runtime_types import AxisSpec, HoleSpec, PlaneSpec, TopologyRecord, Vector3, canonical_plane_signature
@@ -201,13 +201,23 @@ class Build123dGeometryAdapter:
def revolve(face: Face, angle_deg: float, axis: AxisSpec) -> Solid:
return Solid.revolve(face, angle_deg, Build123dGeometryAdapter.axis(axis))
@staticmethod
def _body_shape(value: Any) -> Any:
"""Normalize boolean results, including disconnected ShapeList values."""
if hasattr(value, "bounding_box"):
return value
shapes = list(value)
if not shapes:
raise ValueError("Boolean operation produced no shapes")
return shapes[0] if len(shapes) == 1 else Compound(shapes)
@staticmethod
def fuse(body: Any | None, solid: Solid) -> Any:
return solid if body is None else body.fuse(solid)
return solid if body is None else Build123dGeometryAdapter._body_shape(body.fuse(solid))
@staticmethod
def cut(body: Any, tool: Any) -> Any:
return body.cut(tool)
return Build123dGeometryAdapter._body_shape(body.cut(tool))
@staticmethod
def sphere(radius_mm: float, center_mm: Vector3) -> Solid: