From 549bc0e1a9b5d4cb44f58dff4c2322d5d11d6cd3 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 4 Jul 2021 20:22:20 +1000 Subject: [PATCH] Minor fix. See #1475. --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 5 +++-- src/ifcopenshell-python/ifcopenshell/util/element.py | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 86e6c3dfba..078047790a 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -118,8 +118,6 @@ class entity_instance(object): def __setattr__(self, key, value): index = self.wrapped_data.get_argument_index(key) - if self.wrapped_data.file.transaction: - self.wrapped_data.file.transaction.store_edit(self, index, value) self[index] = value def __getitem__(self, key): @@ -128,6 +126,9 @@ class entity_instance(object): return entity_instance.wrap_value(self.wrapped_data.get_argument(key), self.wrapped_data.file) def __setitem__(self, idx, value): + if self.wrapped_data.file.transaction: + self.wrapped_data.file.transaction.store_edit(self, idx, value) + attr_type = real_attr_type = self.attribute_type(idx).title().replace(" ", "") real_attr_type = real_attr_type.replace("Derived", "None") attr_type = attr_type.replace("Binary", "String") diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index b2d113c7ef..f245f9b4e8 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -93,9 +93,6 @@ def replace_attribute(element, old, new): for i, attribute in enumerate(element): if has_element_reference(attribute, old): new_attribute = element.walk(lambda v: v == old, lambda v: new, attribute) - # TODO: make this unnecessary - if element.wrapped_data.file.transaction: - element.wrapped_data.file.transaction.store_edit(element, i, new_attribute) element[i] = new_attribute