There are many scenarios like inside modeless dialog box or inside Palette, programmers need to know whether a command is running or a jugging is happening in AutoCAD. In such scenarios, to identify the state of AutoCAD, you can use below functions.
To identify the running commands: read the system variable “CMDNAMES”
To identify the jigging status, call the editor function “IsDragging”
//AutoCADAppServices is defined as
//using AutoCADAppServices = Autodesk.AutoCAD.ApplicationServices;
Document doc = AutoCADAppServices.Application.
DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
object names =
AutoCADAppServices.Application.GetSystemVariable("CMDNAMES");
string strText = names as string;
if (strText.Length != 0)
ed.WriteMessage(strText + " command is running\n");
else
ed.WriteMessage("No command is running\n");
if (ed.IsDragging)
{
ed.WriteMessage("Dragging is in progress\n");
}
