Fix #2001. Fix bug where you could not undo deletions.

This commit is contained in:
Dion Moult
2022-01-25 17:27:42 +11:00
parent 8fd4351195
commit e129f4afa9
2 changed files with 18 additions and 1 deletions
+17
View File
@@ -186,6 +186,23 @@ class IfcStore:
data["guid"] = element.GlobalId
IfcStore.commit_link_element(data)
@staticmethod
def delete_element(element):
IfcStore.deleted_ids.add(element.id())
if IfcStore.history:
data = {"id": element.id()}
IfcStore.history[-1]["operations"].append(
{"rollback": IfcStore.rollback_delete_element, "commit": IfcStore.commit_delete_element, "data": data}
)
@staticmethod
def rollback_delete_element(data):
IfcStore.deleted_ids.remove(data["id"])
@staticmethod
def commit_delete_element(data):
IfcStore.deleted_ids.add(data["id"])
@staticmethod
def link_element(element, obj):
IfcStore.id_map[element.id()] = obj
@@ -330,7 +330,7 @@ class OverrideDeleteTrait:
def delete_ifc_object(self, obj):
if obj.BIMObjectProperties.ifc_definition_id:
element = IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id)
IfcStore.deleted_ids.add(element.id())
IfcStore.delete_element(element)
if getattr(element, "FillsVoids", None):
self.remove_filling(element)
if element.is_a("IfcOpeningElement"):