Proper methods for transaction in Revit

transaction
dynamo
zerotouch
#1

Hello fellow zero touch developers,

What is the proper way to complete a transaction in Revit (in a dynamo zero-touch node)? I have seen these but not sure what the difference is? Does it matter which set of methods/commands I use in my zero touch nodes? Cannot find any api documention for RevitServices that explains this…

Any explanation would be appreciated. Thanks!

example:

Document doc = DocumentManager.Instance.CurrentDBDocument;
using (Transaction t = new Transaction(doc))
    {
    t.Start();
    //perform some task in current Revit file
    t.Commit();
    }
}
TransactionManager.Instance.TransactionTaskDone();

or this?

Document doc = DocumentManager.Instance.CurrentDBDocument;            
TransactionManager.Instance.EnsureInTransaction(doc);
//do something in Revit here
TransactionManager.Instance.TransactionTaskDone();
#2

This might be helpful:

1 Like
#3

@danieljackieucla

Also refer to the following


1 Like
#4

Thanks @salvatoredragotta. Is there documentation for how to do this in C#? I am working primarily in C# for zero-touch node development. Thanks for any input.

#5

check the revit api documentation website http://www.revitapidocs.com/2018.2/308ebf8d-d96d-4643-cd1d-34fffcea53fd.htm
there are plenty of examples in C#