AutoCAD .NET Command Flags can be categorized into two major groups, the primary flags and secondary ones.
The primary Command Flags have only two, Modal and Transparent.
The second Command Flags have quite a few:
UsePickSet
Redraw
Session
Interruptible
DocExclusiveLock
DocReadLock
NoInternalLock
NoPaperSpace
NoTileMode
NoPerspective
NoBlockEditor
ActionMacro
NoActionRecording
NoHistory
NoMultiple
NoUndoMarker
NoNewStack
NoOem
Defun
InProgress
Undefined
We are going to focus on one of the secondary command flags, the CommandFlags.Undefined, in this post.
The CommandFlags.Undefined indicates that the command cannot be invoked by its own name directly. Instead, it is supposed that the fully qualified command name should be used, i.e. CommandGroupName + GlobalCommandName, so as to invoke the command.
We are going to create such a command specifying the CommandFlags.Undefined. Here it is:
[CommandMethod("CmdGroup1", "Command28", null, CommandFlags.Modal | CommandFlags.Undefined, null, "Acad2028NetDemoAddinCS.chm", "Command28")]
public void Command28_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
//TODO: add your code below.
ed.WriteMessage("Command28 ran.");
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
Here are the command outputs for the command having CommandFlags.Undefined specified:
Command: COMMAND28
Unknown command "COMMAND28". Press F1 for help.
Command: CMDGROUP1.COMMAND28
Unknown command "COMMAND28". Press F1 for help.
Command: ARX
Enter an option [Files/Groups/Commands/CLasses/Services/Load/Unload]: commands
Enter commands(s) to list <*>: *
Commands Registered by Extension Programs:
Command Group 'ACAD_MAIN'
*SCROLL, *SCROLL
+CUSTOMIZE, +CUSTOMIZE
…
…
Command Group 'CmdGroup1'
COMMAND1, COMMAND1
COMMAND10, COMMAND10
COMMAND11, COMMAND11
COMMAND12, COMMAND12
COMMAND13, COMMAND13
COMMAND14, COMMAND14
COMMAND15, COMMAND15
COMMAND16, COMMAND16
COMMAND17, COMMAND17
COMMAND18, COMMAND18
COMMAND19, COMMAND19
COMMAND2, COMMAND2
COMMAND20, COMMAND20
COMMAND21, COMMAND21
Press ENTER to continue:
COMMAND22, COMMAND22
COMMAND23_MULTIPLE, COMMAND23_MULTIPLE
COMMAND23_NOMULTIPLE, COMMAND23_NOMULTIPLE
COMMAND24, COMMAND24
COMMAND25, COMMAND25
COMMAND26, COMMAND26
COMMAND28, COMMAND28
COMMAND3, COMMAND3
COMMAND4, COMMAND4
COMMAND5, COMMAND5
COMMAND6, COMMAND6
COMMAND7, COMMAND7
COMMAND8, COMMAND8
COMMAND9, COMMAND9
…
…
Out of expectations, both the COMMAND28 and the CMDGROUP1.COMMAND28 failed to invoke the command. However, as can be noticed from the ARX Commands output the Command28 of the command group cmdGroup1 is clearly there. There must be something wrong elsewhere!
By the way, all the command definition code was generated automatically by using AutoCAD .NET Addin Wizard (AcadNetAddinWizard).
The following illustration shows where the CommandFlags.Undefined command flag is on the wizard page:
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) can create commands with any good combinations of all available CommandFlags optionally, flexibly, intelligently, and automatically.
Try enter a single period before the command name, i.e. ".COMMAND28".
Preceding a command name with a period (.) ensures that the built-in AutoCAD command is accessed, and not an application-defined command of the same name that has been defined to override the built-in command using UNDEFINE.
For example if you use the UNDEFINE command on the CIRCLE command, you can still access the command by preceding the command name with a period, i.e. ".CIRCLE".
So it looks like the CommandFlags.Undefined enum automatically undefines the command.
Posted by: jimmy | 08/10/2012 at 04:35 PM
Ah, that's what the Undefined CommandFlags enum is really supposed to mean then. Pretty interesting! Thanks a lot for figuring it out and sharing the info here.
The 'official' doc is wrong about it then, as suspected, "Command can only be invoked via the cmdGroupName.cmdGlobalName syntax."
Thanks again.
Posted by: Spiderinnet1 | 08/10/2012 at 06:11 PM