From d9f1cb5525f57e7b2ea78647c730f74d62405032 Mon Sep 17 00:00:00 2001 From: Vukas Pajic Date: Mon, 16 Jan 2023 13:34:57 +0100 Subject: [PATCH] reassign_class now preserves original STEP ID and GLOBALID - #2701 --- src/ifcopenshell-python/ifcopenshell/util/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/schema.py b/src/ifcopenshell-python/ifcopenshell/util/schema.py index 322cc3d760..7a5f2bcce5 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/util/schema.py @@ -50,7 +50,8 @@ def get_subtypes(entity): def reassign_class(ifc_file, element, new_class): try: - new_element = ifc_file.create_entity(new_class) + new_element = ifcopenshell.create_entity(new_class) + new_element.GlobalId = element.GlobalId except: print(f"Class of {element} could not be changed to {new_class}") return element @@ -63,6 +64,7 @@ def reassign_class(ifc_file, element, new_class): for inverse in ifc_file.get_inverse(element): ifcopenshell.util.element.replace_attribute(inverse, element, new_element) ifc_file.remove(element) + ifc_file.add(new_element, element.id()) return new_element