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"""