Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public static void SendACommandToAutoCAD(string command)
  2. {
  3. MgdAcDocument doc = MgdApplication.DocumentManager.MdiActiveDocument;
  4. if(doc == null)
  5. {
  6. MessageBox.Show("当前无活动文档,请新建或切换至活动文档后再执行命令", "无法获取活动文档", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  7. return;
  8. }
  9. // 根据是否有命令运行决定esc的数量
  10. string esc = "";
  11. string cmds = (string)MgdApplication.GetSystemVariable("CMDNAMES");
  12. if (cmds.Length > 0)
  13. {
  14. int cmdNum = cmds.Split(new char[] { '\'' }).Length;
  15. for (int i = 0; i < cmdNum; i++)
  16. {
  17. esc += '\x03';
  18. }
  19. }
  20. doc.SendStringToExecute(esc + "_." + command + " ", true, false, true);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement