命令定义
 
 

当定义一个命令时,应该使用 CommandMethod 属性。 CommandMethod 属性期待一个字符串值,它将当作被定义命令的全局名称。和全局命令名称一起,CommandMethod 属性还能接受如下值:

下面的表格列出了可用的可以用于定义命令行为的 Flags 值

枚举值 说明
ActionMacro

Command can be recorded as an action with the Action Recorder.

命令可以使用 Action Recorder 作为动作被记录。

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.

命令不可以使用 Action Recorder 作为动作被记录。

NoBlockEditor

Command cannot be used from the Block Editor.

命令不能在块编辑器中使用。

NoHistory

Command is not added to the repeat-last-command history list.

命令不能添加到“近期使用的命令”历史列表中。

NoPaperSpace

Command cannot be used from Paper space.

命令不能在图纸空间中使用。

NoTileMode

Command cannot be used when TILEMODE is set to 1.

当 TILEMODE 设置为 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.

命令是在应用程序环境中执行而不是当前文档环境中

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.

 

定义命令的语法

下面演示了使用CommandMethod属性定义了一个名为 CheckForPickfirstSelection 的命令。该属性还使用命令标志 UsePickSet 以指示该命令允许使用该命令之前选定的对象。

VB.NET

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

C#

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

可以指定使用多于一个的 Flag,在 VB.NET 中使用+操作符连接而在 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()
{
 . . .
}