TransactionGroup Class

Transaction groups aggregate a number of transactions.
Inheritance Hierarchy
SystemObject
  Autodesk.Revit.DBTransactionGroup

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
 NameDescription
Public methodTransactionGroup(Document) Constructs a transaction group object.
Public methodTransactionGroup(Document, String) It constructs a transaction group object
Top
Properties
 NameDescription
Public propertyIsFailureHandlingForcedModal Forces all transactions finished inside this group to use modal failure handling regardless of what failure handling options are set for those transactions.
Public propertyIsValidObject Specifies whether the .NET object represents a valid Revit entity.
Top
Methods
 NameDescription
Public methodCode exampleAssimilate Assimilates all inner transactions by merging them into a single undo item.
Public methodCode exampleCommit Commits the transaction group.
Public methodDisposeReleases all resources used by the TransactionGroup
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetName Returns the transaction group's name. It could be an empty string.
Public methodGetStatus Gets the current status of the transaction group.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodHasEnded Determines whether the transaction group has ended already.
Public methodHasStarted Determines whether the transaction has been started yet.
Public methodRollBack Rolls back the transaction group, which effectively undoes all transactions committed inside the group.
Public methodSetName Sets the transaction group's name.
Public methodStart Starts the transaction group
Public methodStart(String) Starts the transaction group with an assigned name.
Public methodToStringReturns 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