Starts the transaction with an assigned name.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Syntax
Parameters
- name
- Type: System..::..String
Name of the transaction; If the transaction already has name, this new one will preplace it.
The name will appear on the Undo menu in Revit if the transaction is successfully committed.
Return Value
If finished successfully, this method returns TransactionStatus.Started.
Note that unless starting is successful, changes cannot be made to the document.
Remarks
Examples
CopyC#
public bool TransactionBoundaries(Autodesk.Revit.DB.Document document)
{
bool result = false;
using (Transaction transaction = new Transaction(document))
{
transaction.Start("Transaction name");
if (result == true)
{
if (TransactionStatus.Committed != transaction.Commit())
{
result = false;
}
}
else
{
transaction.RollBack();
}
}
return result;
}
CopyVB.NET
Public Function TransactionBoundaries(document As Autodesk.Revit.DB.Document) As Boolean
Dim result As Boolean = False
Using transaction As New Transaction(document)
transaction.Start("Transaction name")
If result = True Then
If TransactionStatus.Committed <> transaction.Commit() Then
result = False
End If
Else
transaction.RollBack()
End If
End Using
Return result
End Function
Exceptions
Exception | Condition |
---|
Autodesk.Revit.Exceptions..::..ArgumentException |
The name argument is an empty string.
|
Autodesk.Revit.Exceptions..::..ArgumentNullException |
A non-optional argument was NULL
|
Autodesk.Revit.Exceptions..::..InvalidOperationException |
Cannot modify the document for either a read-only external command is being executed, or changes to the document are temporarily disabled.
-or-
The transaction's document is currently in failure mode.
No transaction operations are permitted until failure handling is finished.
-or-
The transaction started already and has not been completed yet.
-or-
Starting a new transaction is not permitted. It could be because
another transaction already started and has not been completed yet,
or the document is in a state in which it cannot start a new transaction
(e.g. during failure handling or a read-only mode, which could be either permanent or temporary).
|
See Also