AutoCAD .NET Command Flags can be categorized into two major groups, 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, CommandFlags.NoInternalLock, in this post.
The CommandFlags.NoInternalLock may indicate that the internal lock will not be imposed additionally over to the current command.
We are going to create two sample commands to compare the behavior between specifying the CommandFlags.NoInternalLock and not. Here are they:
/// <summary>
/// The command demonstrating the behavior of the NoInternalLock command flag.
/// </summary>
[CommandMethod("CmdGroup1", "Command15", null, CommandFlags.Modal | CommandFlags.NoInternalLock, null, "Acad2015NetDemoAddinCS.chm", "Command15")]
public void Command15_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
ed.WriteMessage(AcadApplication.DocumentManager.MdiActiveDocument.LockMode().ToString());
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
/// <summary>
/// The command demonstrating the behavior of without the NoInternalLock command flag.
/// </summary>
[CommandMethod("CmdGroup1", "Command13", null, CommandFlags.Modal, null, "Acad2012NetDemoAddinCS.chm", "Command13")]
public void Command13_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
ed.WriteMessage(AcadApplication.DocumentManager.MdiActiveDocument.LockMode().ToString());
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
It is also demonstrated how to check the lock mode of the active document through calling the Document.LockMode method. Here are the command outputs for the two commands:
Command: Command13
Write
Command: Command15
Write
So the two commands behave the same indicating the CommandFlags.NoInternalLock does not impose any other lock onto the command. Then we can reasonably reach the conclusion that we can live without the CommandFlags.NoInternalLock.
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.NoInternalLock 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.
Posted by: |