TransactionManager vs Transaction

I typically use Revit.DB.Transaction() object

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

But most code samples I see, and the Dynamo wiki page suggests the RevitServicesTransactions.TransactionManager

from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Do stuff

Are there any disadvantages to using DB.Transaction or
advantages in using TransactionManager?

The wiki page mentions “There is no way to rollback the main Dynamo Transaction”, so that seems to be +1 for typical transactions. Any other differences?


What is your goal? Are you looking to temporarily delete elements in order to get a list of affected elements?

The transaction manager is just a layer around the regular revit transactions that manages them for you. It’s preferable to use it instead of regular transactions because that way, if your script crashes before a transaction can be committed, the manager will make sure to finalize everything and do all the necessary cleanup. Otherwise you’ll end up with a stray open transaction, at least until revit’s built-in utilities can clean it up.

If you need to do any rollbacks, you can always open a sub-transaction inside a dynamo controlled transaction. Sub-transaction can only exist in an open transaction and should not be able to lock down your document.


Thank you @Dimitar_Venkov
@Andreas_Dieckmann, not specif issue, I was just trying to understand the difference.