From 6294c35a11a988d4360c5dcbeb350c472631431f Mon Sep 17 00:00:00 2001 From: DesertSpringsCivil Date: Sun, 1 Feb 2026 18:40:49 -0700 Subject: [PATCH] Handle RuntimeError in alignment geometry generation Add RuntimeError handling for IfcOpenShell versions that don't support the piecewise-step-type setting in geometry generation. Co-Authored-By: Claude Opus 4.5 --- src/bonsai/bonsai/tool/alignment.py | 3 ++- src/ifcopenshell-python/ifcopenshell/api/alignment/util.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/alignment.py b/src/bonsai/bonsai/tool/alignment.py index 6ee4958bc1..c7fa073ed9 100644 --- a/src/bonsai/bonsai/tool/alignment.py +++ b/src/bonsai/bonsai/tool/alignment.py @@ -308,7 +308,8 @@ class Alignment: # Generate vertices using IfcOpenShell's geometry engine try: vertices = align_util.generate_vertices(rep_curve, distance_interval=1.0) - except (ValueError, NotImplementedError): + except (ValueError, NotImplementedError, RuntimeError): + # RuntimeError can occur if IfcOpenShell version doesn't support certain settings return None if len(vertices) < 2: diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py index c36e635768..bb9578f199 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/util.py @@ -90,7 +90,10 @@ def generate_vertices(rep_curve: entity_instance, distance_interval: float = 5.0 ) s = ifcopenshell.geom.settings() - s.set("piecewise-step-type", 0) # 0 = step-size is maximum step size, 1 = step-size is mininimum number of steps + try: + s.set("piecewise-step-type", 0) # 0 = step-size is maximum step size, 1 = step-size is mininimum number of steps + except RuntimeError: + pass # Setting not available in older IfcOpenShell versions s.set("piecewise-step-size", distance_interval) shape = ifcopenshell.geom.create_shape(s, rep_curve) vertices = shape.verts