Issue: Starting a new transaction is not permitted

Why don’t you use the Transaction Manager? This class is designed to overcome this kind of troubles

There is also a method called ForceCloseTransactions

Import the Revit Services
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

#your Code Goes here

#End Transaction
TransactionManager.Instance.TransactionTaskDone()

I would also be good to use the “with” statement in Python:

with Transaction(doc,"SomeTranseAction") as transaction:
   transaction.Start()
   #Your Code Goes Here
   transaction.Commit()

The “with” statement makes sure to dispose (throw away) the Transaction Object after you are done with it.

3 Likes