reassign_class now preserves original STEP ID and GLOBALID - #2701

This commit is contained in:
Vukas Pajic
2023-01-16 13:34:57 +01:00
committed by GitHub
parent 8110951987
commit d9f1cb5525
@@ -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