Skip to content

Commit

Permalink
Fixed lock button staying On when unable to lock - fixes #63
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 25, 2024
1 parent ebf5805 commit 5a85a4d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ifc_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def set_status_widget(statuswidget):
statuswidget.lock_button = lock_button


def toggle_lock(checked):
def toggle_lock(checked=False):
"""Sets the lock button on/off"""

from PySide import QtGui # lazy loading
Expand Down Expand Up @@ -119,6 +119,7 @@ def lock_document():
import ifc_tools # lazy loading
import exportIFC
import ifc_geometry
from PySide import QtCore

doc = FreeCAD.ActiveDocument
products = []
Expand Down Expand Up @@ -155,12 +156,15 @@ def lock_document():
pass
doc.removeObject(project.Name)
doc.Modified = True
# all objects have been deleted, we need to show at least something
if not doc.Objects:
ifc_tools.create_children(doc, ifcfile, recursive=True)
doc.commitTransaction()
doc.recompute()
elif len(projects) > 1:
# 2 there is more than one project
FreeCAD.Console.PrintError("Unable to lock this document because it contains several IFC documents\n")
toggle_lock(False)
QtCore.QTimer.singleShot(100, toggle_lock)
elif doc.Objects:
# 3 there is no project but objects
doc.openTransaction("Lock document")
Expand Down

0 comments on commit 5a85a4d

Please sign in to comment.