TransactionGroup Class


Transaction Group Class

Transaction groups aggregate a number of transactions.
Inheritance Hierarchy
System Object
Autodesk.Revit.DB TransactionGroup

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class TransactionGroup : IDisposable

The TransactionGroup type exposes the following members.

Constructors
Name Description
Public method TransactionGroup(Document) Constructs a transaction group object.
Public method TransactionGroup(Document, String) It constructs a transaction group object
Top
Properties
Name Description
Public property IsFailureHandlingForcedModal Forces all transactions finished inside this group to use modal failure handling regardless of what failure handling options are set for those transactions.
Public property IsValidObject Specifies whether the .NET object represents a valid Revit entity.
Top
Methods
Name Description
Public method Code example Assimilate Assimilates all inner transactions by merging them into a single undo item.
Public method Code example Commit Commits the transaction group.
Public method Dispose Releases all resources used by the TransactionGroup
Public method Equals Determines whether the specified object is equal to the current object.
(Inherited from Object )
Public method GetHashCode Serves as the default hash function.
(Inherited from Object )
Public method GetName Returns the transaction group's name. It could be an empty string.
Public method GetStatus Gets the current status of the transaction group.
Public method GetType Gets the Type of the current instance.
(Inherited from Object )
Public method HasEnded Determines whether the transaction group has ended already.
Public method HasStarted Determines whether the transaction has been started yet.
Public method RollBack Rolls back the transaction group, which effectively undoes all transactions committed inside the group.
Public method SetName Sets the transaction group's name.
Public method Start Starts the transaction group
Public method Start(String) Starts the transaction group with an assigned name.
Public method ToString Returns a string that represents the current object.
(Inherited from Object )
Top
Remarks

A transaction group controls whether transactions committed inside the group should stay committed or should be all discarded. If the group is committed, all the transactions remain committed, but if the transaction group is rolled back instead, all the inner, already committed transactions will be undone (and removed).

There are two ways of committing a group - Commit and Assimilate. By committing, all transactions committed inside a group stay as they are, while by assimilating, all inner transactions will be merged into a single transaction.

A transaction group can only be started when no transaction is active, and must be closed only after the last transaction started inside the group is finished, i.e. after it was either committed or rolled back.

Transaction groups may be nested inside each other with the restriction that every nested transaction group is entirely contained (opened and closed) in the parent transaction group.

If a transaction group was started and not finished yet by the time the TransactionGroup object is about to be, the default destructor will roll it back automatically, thus all changes made to the document while this transaction group was open will be discarded. It is not recommended to rely on this default behavior though. Instead, it is advised to always call either Commit , RollBack , or Assimilate explicitly before the group object gets destroyed. Please note that unless invoked explicitly the actual destruction of an object in managed code might not happen until the object is collected by the garbage collector.

See Also