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.
Editor ed = doc.Editor;
object names =
string strText = names as string;
if (strText.Length != 0)
ed.WriteMessage(strText + " command is running\n");
ed.WriteMessage("No command is running\n");
ed.WriteMessage("Dragging is in progress\n");