From 5879d1480346d2be4b18b5f6d58c5d9929aee86d Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 7 Feb 2023 09:03:00 +1100 Subject: [PATCH] See #2737. Fix bug where convert length unit patch did not work outside Blender session. --- src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py b/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py index 722c30aff9..3c60601e5e 100644 --- a/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py +++ b/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py @@ -53,8 +53,11 @@ class Patcher: self.file_patched = ifcopenshell.api.run("project.create_file", version=self.file.schema) if self.file.schema == "IFC2X3": user = self.file_patched.add(self.file.by_type("IfcProject")[0].OwnerHistory.OwningUser) + application = self.file_patched.add(self.file.by_type("IfcProject")[0].OwnerHistory.OwningApplication) old_get_user = ifcopenshell.api.owner.settings.get_user + old_get_application = ifcopenshell.api.owner.settings.get_application ifcopenshell.api.owner.settings.get_user = lambda ifc: user + ifcopenshell.api.owner.settings.get_application = lambda ifc: application project = ifcopenshell.api.run("root.create_entity", self.file_patched, ifc_class="IfcProject") unit_assignment = ifcopenshell.api.run("unit.assign_unit", self.file_patched, **{"length": unit}) @@ -82,3 +85,4 @@ class Patcher: if self.file.schema == "IFC2X3": ifcopenshell.api.owner.settings.get_user = old_get_user + ifcopenshell.api.owner.settings.get_application = old_get_application