*寻找我的“简易按钮”*
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.Runtime;
- using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
- [assembly: CommandClass(typeof(CADTutor.Sample.OpenDocInSdiMode.Commands))]
- namespace CADTutor.Sample.OpenDocInSdiMode
- {
- public class Commands
- {
- [CommandMethod("FOO")]
- public void FOO()
- {
- Document doc = acApp.DocumentManager.MdiActiveDocument;
- // if document has not been titled,
- if (System.Convert.ToInt16(acApp.GetSystemVariable("DWGTITLED")) != 1
- // or has unsaved changes
- | System.Convert.ToInt16(acApp.GetSystemVariable("DBMOD")) != 0)
- // save the document
- doc.SendStringToExecute("._QSAVE\n", false, false, true);
- // then prompt to open another document
- doc.SendStringToExecute("._OPEN\n", false, false, true);
- }
- }
- }
**注意-我将SendStringToExecute()方法的echoCommand参数保留为true,因为当显示仅表示“选择文件”的“打开”对话框时,我发现它可能会令人困惑考虑到要打开的文档的文件名是已知的,您可能希望将其更改为false,因此在命令行中不会回显任何内容。
|