zoukankan      html  css  js  c++  java
  • autocad.net回退undo与命令行回应cmdecho完美结合

    #if AC2013
    
        [DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")]
    
    #else
    
        [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCmd")]
    
    #endif
    
        private static extern int acedCmd(System.IntPtr vlist);
    
        [CommandMethod("ClearUndoStack")]
    
        public void ClearUndoStack()
    
        {
    
          // remember the cmdecho
    
          short cmdecho = (short)Application.GetSystemVariable("CMDECHO");
    
          // turn it off
    
          Application.SetSystemVariable("CMDECHO", 0);
    
     
    
          short undoCtl = (short)Application.GetSystemVariable("UNDOCTL");
    
          bool isOn = (undoCtl & 1) == 1;
    
          if (!isOn)
    
            return;
    
     
    
          bool isOneCmd = (undoCtl & 2) == 2;
    
          bool isAuto = (undoCtl & 4) == 4;
    
     
    
          ResultBuffer rb = new ResultBuffer();
    
          // RTSTR = 5005
    
          rb.Add(new TypedValue(5005, "_.UNDO"));
    
          rb.Add(new TypedValue(5005, "_Control"));
    
          rb.Add(new TypedValue(5005, "_None"));
    
          rb.Add(new TypedValue(5005, "_.UNDO"));
    
     
    
          if (isOneCmd)
    
            rb.Add(new TypedValue(5005, "_One"));
    
          else
    
          {
    
            rb.Add(new TypedValue(5005, "_All"));
    
            if (!isAuto)
    
            {
    
              rb.Add(new TypedValue(5005, "_.UNDO"));
    
              rb.Add(new TypedValue(5005, "_Auto"));
    
              rb.Add(new TypedValue(5005, "_Off"));
    
            }
    
          }
    
     
    
          // start the insert command
    
          acedCmd(rb.UnmanagedObject);
    
          // now restore cmdecho
    
          Application.SetSystemVariable("CMDECHO", cmdecho);
    
        }
  • 相关阅读:
    宝塔nginx配置
    宝塔apache配置
    公司代码规范
    发送短信倒计时
    js layui 分页脚本
    常用mysql
    win10子系统ubuntu下安装nodejs,并使用n管理版本
    Cocos Creator 热更新文件MD5计算和需要注意的问题
    android app 闪屏
    关于模板测试几个问题
  • 原文地址:https://www.cnblogs.com/swtool/p/SWTOOL_00017.html
Copyright © 2011-2022 走看看