TransactionSetName Method |
Sets the transaction's name.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic void SetName(
string name
)
Public Sub SetName (
name As String
)
public:
void SetName(
String^ name
)
member SetName :
name : string -> unit
Parameters
- name String
-
A name for the transaction.
Exceptions
Remarks
A transaction needs a name before it can be started, i.e. before one
of the 'Start' method is invoked for this transaction object.
The name will later appear in the Undo menu in Revit after a transaction
is successfully committed.
Another ways of setting the name is either during construction
or during the Start(String) method.
Examplepublic bool ModelChangingMethod(Autodesk.Revit.DB.Document document)
{
bool result = false;
using (Transaction transaction = new Transaction(document))
{
transaction.Start();
if (result == true)
{
transaction.SetName("Model change");
if (TransactionStatus.Committed != transaction.Commit())
{
result = false;
}
}
else
{
transaction.RollBack();
}
}
return result;
}
Public Function ModelChangingMethod(document As Autodesk.Revit.DB.Document) As Boolean
Dim result As Boolean = False
Using transaction As New Transaction(document)
transaction.Start()
If result = True Then
transaction.SetName("Model change")
If TransactionStatus.Committed <> transaction.Commit() Then
result = False
End If
Else
transaction.RollBack()
End If
End Using
Return result
End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also