From 0f3b570800d174786198ee450540dd789029690c Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 15 Jul 2025 13:05:26 +0500 Subject: [PATCH] Fix get_segment_length bug with non-parametrized profiles (f9c4b6a) `settings` wasn't defined, so `create_shape` was always resulting in an error. Also, `create_shape` is returning `Triangulation` in this kind of cases, so there's no `.geometry`. Also removed IfcCircleProfileDef if-check since it's covered by IfcParameterizedProfileDef. --- src/ifc5d/ifc5d/qto.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ifc5d/ifc5d/qto.py b/src/ifc5d/ifc5d/qto.py index 37c21a5ec2..928e00b38e 100644 --- a/src/ifc5d/ifc5d/qto.py +++ b/src/ifc5d/ifc5d/qto.py @@ -23,6 +23,7 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.geom +import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.unit import ifcopenshell.util.element import ifcopenshell.util.selector @@ -358,16 +359,17 @@ class IfcOpenShell(QtoCalculator): y = item.SweptArea.YDim z = item.Depth return max([x, y, z]) - elif item.SweptArea.is_a("IfcCircleProfileDef"): - return item.Depth elif item.SweptArea.is_a("IfcParameterizedProfileDef"): return item.Depth + settings = ifcopenshell.geom.settings() + settings.set("dimensionality", ifcopenshell.ifcopenshell_wrapper.CURVES_SURFACES_AND_SOLIDS) try: area_shape = ifcopenshell.geom.create_shape(settings, item.SweptArea) - except: + except RuntimeError: return - x = ifcopenshell.util.shape.get_x(area_shape.geometry) / cls.unit_scale - y = ifcopenshell.util.shape.get_y(area_shape.geometry) / cls.unit_scale + assert isinstance(area_shape, W.Triangulation) + x = ifcopenshell.util.shape.get_x(area_shape) / cls.unit_scale + y = ifcopenshell.util.shape.get_y(area_shape) / cls.unit_scale z = item.Depth return max([x, y, z])