Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void SendACommandToAutoCAD(string command)
- {
- MgdAcDocument doc = MgdApplication.DocumentManager.MdiActiveDocument;
- if(doc == null)
- {
- MessageBox.Show("当前无活动文档,请新建或切换至活动文档后再执行命令", "无法获取活动文档", MessageBoxButtons.OK, MessageBoxIcon.Stop);
- return;
- }
- // 根据是否有命令运行决定esc的数量
- string esc = "";
- string cmds = (string)MgdApplication.GetSystemVariable("CMDNAMES");
- if (cmds.Length > 0)
- {
- int cmdNum = cmds.Split(new char[] { '\'' }).Length;
- for (int i = 0; i < cmdNum; i++)
- {
- esc += '\x03';
- }
- }
- doc.SendStringToExecute(esc + "_." + command + " ", true, false, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement