From 1e6db764d4bd71cf879454be94be105b6aba6ff3 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Tue, 26 May 2026 16:58:40 +0200 Subject: [PATCH] Add numpy axis-index constants + silence MEP-transition prints ShapeBuilder gains module-level NP_X / NP_Y / NP_Z / NP_XY / NP_XZ / NP_YZ / NP_YX axis-index constants. Downstream geometry builders had been redefining local copies for indexing np.ndarray vectors of shape (3,) or (N, 3); centralising removes the duplication. mep_transition_length and mep_transition_calculate verbose default flipped from True to False. The prints are diagnostic-only output; True-by-default spammed the console on every transition computation, which fires per-fitting on IFC load. Generated with the assistance of an AI coding tool. --- .../ifcopenshell/util/shape_builder.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py index e53d069a76..d9d18f0b5f 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py +++ b/src/ifcopenshell-python/ifcopenshell/util/shape_builder.py @@ -35,6 +35,15 @@ import ifcopenshell.util.unit PRECISION = 1.0e-5 +# Numpy axis-index helpers for 3D coordinates. Use these instead of redefining +# local copies in every geometry-builder module — they index ``np.ndarray`` +# vectors of shape ``(3,)`` or ``(N, 3)``. +NP_X, NP_Y, NP_Z = 0, 1, 2 +NP_XY = slice(2) +NP_XZ = [0, 2] +NP_YZ = [1, 2] +NP_YX = [1, 0] + if TYPE_CHECKING: # NOTE: mathutils is never used at runtime in ifcopenshell, @@ -1826,7 +1835,7 @@ class ShapeBuilder: end_half_dim: np.ndarray, angle: float, profile_offset: VectorType = (0.0, 0.0), - verbose: bool = True, + verbose: bool = False, ) -> Optional[float]: """Get the transition length for two profile half-dimensions, an angle, and an XY offset. @@ -1838,7 +1847,9 @@ class ShapeBuilder: :param end_half_dim: Half-dimensions of the end profile in the same format. :param angle: Maximum allowed transition angle, in degrees. :param profile_offset: 2D XY offset between the centrelines of the start and end profiles. - :param verbose: If True, print diagnostic values during calculation. + :param verbose: If True, print diagnostic values during calculation. Default is False — + the prints are debug-only output; enabling them spams the console on every transition + geometry computation (which fires per-fitting on IFC load). :return: Transition length in project length units, or ``None`` if no valid length exists for the given angle and offset. """ @@ -1899,7 +1910,7 @@ class ShapeBuilder: end_profile: bool = False, length: Optional[float] = None, angle: Optional[float] = None, - verbose: bool = True, + verbose: bool = False, ) -> Union[float, None]: """Calculate MEP transition length from angle, or transition angle from length.