diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 44f8e1b2f4..19cd633a71 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -51,3 +51,15 @@ def get_properties(properties): del(data['HasProperties']) results[prop.Name] = data return results + + +def replace_attribute(element, old, new): + for i, attribute in enumerate(element): + if attribute == old: + element[i] = new + elif isinstance(attribute, tuple): + new_attribute = list(attribute) + for j, item in enumerate(attribute): + if item == old: + new_attribute[j] = new + element[i] = new_attribute