diff --git a/src/blenderbim/blenderbim/bim/ifc.py b/src/blenderbim/blenderbim/bim/ifc.py index 6390ac630f..3f20975fe3 100644 --- a/src/blenderbim/blenderbim/bim/ifc.py +++ b/src/blenderbim/blenderbim/bim/ifc.py @@ -184,9 +184,13 @@ class IfcStore: def execute_ifc_operator(operator, context): is_top_level_operator = not bool(IfcStore.current_transaction) + file = IfcStore.get_file() + if not file: + return {'FINISHED'} + if is_top_level_operator: IfcStore.begin_transaction(operator) - IfcStore.get_file().begin_transaction() + file.begin_transaction() # This empty transaction ensures that each operator has at least one transaction IfcStore.add_transaction_operation(operator, rollback=lambda data: True, commit=lambda data: True) else: @@ -195,9 +199,9 @@ class IfcStore: result = getattr(operator, "_execute")(context) if is_top_level_operator: - IfcStore.get_file().end_transaction() + file.end_transaction() IfcStore.add_transaction_operation( - operator, rollback=lambda d: IfcStore.get_file().undo(), commit=lambda d: IfcStore.get_file().redo() + operator, rollback=lambda d: file.undo(), commit=lambda d: file.redo() ) IfcStore.end_transaction(operator)