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 two of the secondary command flags, CommandFlags.NoNewStack and CommandFlags.NoOem, in this post.
The CommandFlags.NoNewStack may indicate that the command will not be put onto a new command stack and the CommandFlags.NoOem obviously suggests the command will not be available to OEM products.
We are going to create two sample commands that specify the command flags respectively, CommandFlags.NoNewStack and CommandFlags.NoOem:
/// <summary>
/// The command demonstrating the behavior of the NoNewStack command flag.
/// </summary>
[CommandMethod("CmdGroup1", "Command30", null, CommandFlags.Modal| CommandFlags.NoNewStack, null, "Acad2012NetDemoAddinCS.chm", "Command30")]
public void Command30_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
//TODO: add your code below.
ed.WriteMessage("Command30 ran.");
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
/// <summary>
/// The command demonstrating the behavior of the NoOem command flag.
/// </summary>
[CommandMethod("CmdGroup1", "Command31", null, CommandFlags.Modal| CommandFlags.NoOem, null, "Acad2012NetDemoAddinCS.chm", "Command31")]
public void Command31_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
//TODO: add your code below.
ed.WriteMessage("Command31 ran.");
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
The output will not be demonstrated here since we do not have the OEM environment or a way to verify whether or not the command is put on a new stack. Please go ahead and give them a try if readers have such environments.
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.NoNewStack command flag is on the wizard page:
The following illustration shows where the CommandFlags.NoOem 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.
Recent Comments