From 02621305c9d3d392413e90eeeece8027b4a7af34 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 14 Nov 2024 17:26:42 +0500 Subject: [PATCH] ConvertPropertiesToQuantities - small fix Prevent calling add_qto if quantity set was already found in 'qtos'. --- .../ifcpatch/recipes/ConvertPropertiesToQuantities.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ifcpatch/ifcpatch/recipes/ConvertPropertiesToQuantities.py b/src/ifcpatch/ifcpatch/recipes/ConvertPropertiesToQuantities.py index abd9a2110f..105d2d59e2 100644 --- a/src/ifcpatch/ifcpatch/recipes/ConvertPropertiesToQuantities.py +++ b/src/ifcpatch/ifcpatch/recipes/ConvertPropertiesToQuantities.py @@ -96,8 +96,10 @@ class Patcher: has_quantity = True if value and not has_quantity: - qto_name = self.get_qto_name(product.is_a()) - qto = qtos.get(qto_name, ifcopenshell.api.pset.add_qto(self.file, product=product, name=qto_name)) + qto_name = self.get_qto_name(product.is_a()) or "UnnamedQset" + qto = qtos.get(qto_name) + if qto is None: + qto = ifcopenshell.api.pset.add_qto(self.file, product=product, name=qto_name) ifcopenshell.api.pset.edit_qto(self.file, qto=qto, properties={self.destination_quantity_name: value}) def get_qto_name(self, ifc_class: str) -> Union[str, None]: