Command Definition (.NET)

When defining a command, you use the CommandMethod attribute. The CommandMethod attribute expects a string value to use as the global name of the command that is being defined. Along with a global command name, the CommandMethod attribute can accept the following values:

The following table lists the available flags that can be used to define the behavior of a command.

Enum Value Description
ActionMacro Command can be recorded as an action with the Action Recorder.
Defun Command can be invoked as a LISP function and can therefore use acedGetArgs() to receive arguments from LISP and can use the acedRetXxx() functions to return values to LISP. This flag can only be set by the Visual LISP engine.
DocExclusiveLock Document will be exclusively locked when command is invoked.
DocReadLock Document will be read locked when command is invoked.
Interruptible The command may be interrupted when prompting for user input.
Modal Command cannot be invoked while another command is active.
NoActionRecording Command cannot be recorded as action with the Action Recorder.
NoBlockEditor Command cannot be used from the Block Editor.
NoHistory Command is not added to the repeat-last-command history list.
NoInferConstraint Command cannot be used when inferring constraints.
NoInternalLock Document cannot be internally locked.
NoMultiple Command does not support the multiple behavior when prefixed with an astericks (*) as part of a command macro.
NoNewStack Command does not create a new item on the stack.
NoOEM Command cannot be accessed from AutoCAD OEM.
NoPaperSpace Command cannot be used from Paper space.
NoPerspective Command cannot be used when PERSPECTIVE is set to 1.
NoTileMode Command cannot be used when TILEMODE is set to 1.
NoUndoMarker Command does not support undo markers. This is intended for commands that do not modify the database, and therefore should not show up in the undo file.
Redraw When the pickfirst set or grip set are retrieved, they are not cleared.
Session Command is executed in the context of the application rather than the current document context.
TempShowDynDimension Command allows the display of dynamic dimensions temporarily when entities are selected.
Transparent Command can be used while another command is active.
Undefined Command can only be used via its Global Name.
UsePickSet When the pickfirst set is retrieved, it is cleared.

Syntax to Define a Command

The following demonstrates the creation of a CommandMethod attribute that defines a command named CheckForPickfirstSelection. The attribute also uses the command flag UsePickSet to indicate that the command is allowed to use the objects that are selected before the command is started.

VB.NET

<CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet)> _
Public Sub CheckForPickfirstSelection()
 . . .
End Sub

C#

[CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet)]
public static void CheckForPickfirstSelection()
{
 . . .
}

You can specify the use of more than one flag by using the + operator in VB.NET and the | operator in C#.

VB.NET

<CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet + _
                                             CommandFlags.NoBlockEditor)> _
Public Sub CheckForPickfirstSelection()
 . . .
End Sub

C#

[CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet |
                                             CommandFlags.NoBlockEditor)]
public static void CheckForPickfirstSelection()
{
 . . .
}