I’m building a batch family editor. I would like to add the functionality that if, for a given family, any editing instructions throw an exception, that family is opened in the Family Editor UI.
The current script throws an exception as I’m using OpenAndActivate. I’m looking for JustOpen, if it’s there. I found OpenDocumentFile, is that it?
The exception tells me that I’m not allowed to switch the active document, which makes sense. There is nothing in the UI preventing me to open another document, it just can’t be the active document if Dynamo is to continue to operate on the active document.
So far, saving works:
import clr clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager currentDoc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication family = UnwrapElement(IN) currentDoc = DocumentManager.Instance.CurrentDBDocument doc = currentDoc.EditFamily(family) doc.Save() path=doc.PathName uiapp.OpenAndActivateDocument(path) #throws an exception #https://forums.autodesk.com/t5/revit-api-forum/switching-active-documents-is-not-allowed-during-api-event/td-p/5496940