See #2737. Fix bug where convert length unit patch did not work outside Blender session.

This commit is contained in:
Dion Moult
2023-02-07 09:03:00 +11:00
parent 4c1a821922
commit 5879d14803
@@ -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