Detach central problem

Hi
My script wont work and warning as follow:


Does anyone know the reason?
thanks!

you need add a transaction to detech model

TransactionManager.Instance.EnsureInTransaction(doc)
#Do Detech Model Code
TransactionManager.Instance.TransactionTaskDone()


same :frowning:

maybe need add document event diff becuase you are using open mutiple document, a transaction will be change doc when you open new file project

from Autodesk.Revit.DB import Transaction
t = Transaction(doc, 'Name')
t.Start()
#Do stuff
t.Commit()

with doc is document of file opening

how can I get the doc of file opening?
I just got the file name and path of the model.
I tried GetLinkDocument() but it cant be used on model’s filename.

function OpenDocumentFile return a document for you, let input it for event transaction