From 3b4cd4eab57d4f0c69e5b09f24c81af636f66191 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 15 Nov 2024 16:42:49 +0500 Subject: [PATCH] Fix error editing IfcQuantityCounts in IFC4X3 Full error traceback: Error: Python: Traceback (most recent call last): File "\ifcopenshell\entity_instance.py", line 361, in __setitem__ self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value)) File "\ifcopenshell\ifcopenshell_wrapper.py", line 9271, in setArgumentAsInt return _ifcopenshell_wrapper.entity_instance_setArgumentAsInt(self, i, v) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: in method 'entity_instance_setArgumentAsInt', argument 3 of type 'int' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "\bonsai\bim\ifc.py", line 443, in execute_ifc_operator result = getattr(operator, "_execute")(context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\bonsai\bim\module\pset\operator.py", line 142, in _execute ifcopenshell.api.run( File "\ifcopenshell\api\__init__.py", line 92, in run return usecase_function(ifc_file, should_run_listeners=should_run_listeners, **settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ifcopenshell\api\__init__.py", line 258, in wrapper raise e File "\ifcopenshell\api\__init__.py", line 252, in wrapper result = usecase(*args, **settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\ifcopenshell\api\pset\edit_qto.py", line 135, in edit_qto return usecase.execute() ^^^^^^^^^^^^^^^^^ File "\ifcopenshell\api\pset\edit_qto.py", line 149, in execute self.update_existing_properties() File "\ifcopenshell\api\pset\edit_qto.py", line 166, in update_existing_properties self.update_existing_property(prop) File "\ifcopenshell\api\pset\edit_qto.py", line 180, in update_existing_property prop[3] = float(value) ~~~~^^^ File "\ifcopenshell\entity_instance.py", line 363, in __setitem__ raise TypeError( TypeError: attribute 'CountValue' for entity 'IFC4X3_ADD2.IfcQuantityCount' is expecting value of type 'INT', got 'float'. --- src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py index 23ac329138..65a1993813 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/edit_qto.py @@ -177,7 +177,11 @@ class Usecase: ifcopenshell.api.pset.edit_qto(self.file, qto=prop, properties=value["HasQuantities"]) elif prop.is_a("IfcPhysicalSimpleQuantity"): value = value.wrappedValue if isinstance(value, ifcopenshell.entity_instance) else value - prop[3] = float(value) + # 3 IfcPhysicalSimpleQuantity.XXXValue + if self.file.schema == "IFC4X3" and prop.is_a("IfcQuantityCount"): + prop[3] = int(value) + else: + prop[3] = float(value) del self.settings["properties"][name] def add_new_properties(self) -> list[ifcopenshell.entity_instance]: