//替换CAD中原有命令为开发人员自己开发的命令的方法
//在CAD中执行一次RegisterMyCommand命令后,再执行line时就会loadhead程序了 [CommandMethod("RegisterMyCommand")] public void RegisterMyCommand() { Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.DocumentLockModeChanged += new DocumentLockModeChangedEventHandler(RedefineCommands); } private void RedefineCommands(object sender, DocumentLockModeChangedEventArgs e) { if (e.GlobalCommandName == "LINE") { e.Veto(); LoadHead(); } }