From 8b575785c86fbc35b5733cbfe35a28dab21abeb8 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 25 Mar 2024 14:55:37 +0100 Subject: [PATCH] Sets the lock button at observer start - issue #64 --- ifc_import.py | 5 ++++- ifc_observer.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ifc_import.py b/ifc_import.py index a90d363..7bf9969 100644 --- a/ifc_import.py +++ b/ifc_import.py @@ -67,7 +67,10 @@ def insert( print("Aborted.") return stime = time.time() - document = FreeCAD.getDocument(docname) + try: + document = FreeCAD.getDocument(docname) + except: + document = FreeCAD.newDocument() if singledoc is None: singledoc = params.GetBool("SingleDoc", False) if singledoc: diff --git a/ifc_observer.py b/ifc_observer.py index 43332c2..4865569 100644 --- a/ifc_observer.py +++ b/ifc_observer.py @@ -39,7 +39,11 @@ def add_observer(): class ifc_observer: """A general document observer that handles IFC objects""" - # slots + def __init__(self): + # if there is a document open when the observer starts, + # check it + if FreeCAD.ActiveDocument: + self.slotActivateDocument(FreeCAD.ActiveDocument) def slotStartSaveDocument(self, doc, value): """Save all IFC documents in this doc"""