Open a family in a Family Editor UI, not as Active

Hi all,
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[0])
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

Yes, OpenDocumentFile opens the DB level document in the background. What is the exact exception being thrown? I have used OpenDocumentFile in the past for batch editing of documents within a single directory, but I’m not sure your workflow will work with Dynamo, which only points at a single UIDocument at a given time.

This is the exact excpetion.

From what I have been able to find, I don’t think it’s possible to do exactly what you want (switch to the Family Editor). In order for the family editor to be open, the document is inherently the active document. Given that you cannot switch active documents (as evidenced by the exception), I think your only option is to modify the documents in the background. You can work in some try-except statements to output the name of the specific family (and possibly its category) so the user knows which family to open manually, but I don’t think this can be done automatically.

Alright, makes sense. Thanks for looking in to it! I already made a report output which included a saved path, so that’s as far as it goes, I guess. Good enough.

dynamo automation maybe?
don’t know if @Andreas_Dieckmann 's package allows family editing nor if its still supported.