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);

    }

autocad.net回退undo与命令行回应cmdecho完美结合,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。