The Revit API provides several attributes for configuring ExternalCommand and ExternalApplication behavior.
The custom attribute Autodesk.Revit.Attributes.TransactionMode must be applied to your implementation class of the IExternalCommand interface to control transaction behavior for the external command. There is no default for this option. This mode controls how the API framework expects transactions to be used when the command is invoked. The supported values are:
In either mode, the TransactionMode applies only to the active document. You may open other documents during the course of the command, and you may have complete control over the creation and use of Transactions, SubTransactions, and TransactionGroups on those other documents (even in ReadOnly mode).
For example, to set an external command to use automatic transaction mode:
Code Region 3-18: TransactionAttribute |
[Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Autodesk.Revit.IExternalCommand.Result Execute( Autodesk.Revit.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { // Command implementation, which modifies the active document directly // after starting a new transaction } } |
See Transactions.
The custom attribute Autodesk.Revit.Attributes.JournalingAttribute can optionally be applied to your implementation class of the IExternalCommand interface to control the journaling behavior during the external command execution. There are two options for journaling:
Code Region 3-19: JournalingAttribute |
[Journaling(JournalingMode.UsingCommandData)] public class Command : IExternalCommand { public Autodesk.Revit.IExternalCommand.Result Execute( Autodesk.Revit.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { return Autodesk.Revit.UI.Result.Succeeded; } } |