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 flag, the CommandFlags.Interruptible, in this post.
The CommandFlags.Interruptible indicates that the command is able to interact with other user interfaces such as the OPM (Object Property Manager) or PP (Property Palette) when collecting input from users through calling Editor.GetXXX() methods.
This is not quite applicable in the .NET world actually even in AutoCAD .NET 2012. A sample case might be while acquiring some input during complex jigging the command needs to be interruptible. Use cases have not been worked out so far. In fact, in the ObjectARX world, this kind of commands are pretty useful when getting user input for some custom entity which has enabled the link between command line input and the OPM/PP input through some COM interfaces.
To be a kind reminder, the counterpart command flag in ObjectARX is ACRX_CMD_INTERRUPTIBLE.
We can still see some behaviour difference though between applying the CommandFlags.Interruptible or not in AutoCAD .NET.
Here is the sample command for not using the CommandFlags.Interruptible:
/// <summary>
/// The command demonstrating the behavior of without the Interruptible command flag and user input.
/// </summary>
[CommandMethod("CmdGroup1", "Command10", null, CommandFlags.Modal, null, "Acad2012NetDemoAddinCS.chm", "Command10")]
public void Command10_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
ed.WriteMessage("Not-Interruptible Command10 ran. Please try to select entities with OPM open.\n");
ed.GetSelection();
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
With the OPM open and the above command running, we will notice the OPM looks:
exactly the same as before, indicating the command does not affect the UI at all.
Here is the sample command for using the command flag CommandFlags.Interruptible:
/// <summary>
/// The command demonstrating the behavior of the Interruptible command flag and user input.
/// </summary>
[CommandMethod("CmdGroup1", "Command11", null, CommandFlags.Modal | CommandFlags.Interruptible, null, "Acad2012NetDemoAddinCS.chm", "Command11")]
public void Command11_Method()
{
Editor ed = AcadApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
ed.WriteMessage("Interruptible Command11 ran. Please try to select entities with OPM open.\n");
ed.GetSelection();
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
This time when the command is running (selecting entities in the AutoCAD editor), the OPM looks quite different:
As can be noticed, the interruptible command really tries to communicate with the OPM though obviously lacking some channels in our simplest use.
In order to really demonstrate the behaviour of the command flag CommandFlags.Interruptible, some pretty big other code might have to be created. That is not the major concern for this article. Anyway, hope the above gives you a head-up at least. When necessary and possible, we will revisit this matter in the future.
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.Interruptible 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: |