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.NoBlockEditor, in this post. The CommandFlags.NoBlockEditor indicates that the command will not be allowed in the block editor environment.
We are going to create one command specifying the CommandFlags.NoBlockEditor and check on its behavior. Here it is:
/// <summary>
/// The command demonstrating the behavior of the NoBlockEditor command flag.
/// </summary>
[CommandMethod("CmdGroup1", "Command19", null, CommandFlags.Modal | CommandFlags.NoBlockEditor, null, "Acad2019NetDemoAddinCS.chm", "Command19")]
public void Command19_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
//TODO: add your code below.
ed.WriteMessage("Command19 ran.");
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
Here are some command outputs:
Command: BEDIT
Regenerating model.
Regenerating model.
Regenerating model.
Command: COMMAND19
** COMMAND19 command not allowed in block editor. **
Command:
Command:
Command: _BCLOSE Regenerating model.
Command: COMMAND19
Command19 ran.
By the way, the command definition code was generated automatically by using AutoCAD .NET Addin Wizard (AcadNetAddinWizard). The following illustration shows where the CommandFlags.NoBlockEditor 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