请注意,我不知道他试过VB。那时候的网。可能试过一次,但不喜欢。
我将尝试下一步执行Send字符串(可能是明天)。 *寻找我的“简易按钮”*
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace CADTutor.Sample.OpenDocInSdiMode
{
public class Commands
{
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,因此在命令行中不会回显任何内容。
然后要做更多的阅读
在你的帖子出现之前,我已经尝试了一些事情,这似乎是一条可行的道路。
我不必添加“保存?”开放式对话为我提供舞台。如果绘图已更改,系统会询问您是否要保存它,因为保存并不总是需要的,这对我来说很有效。
我看不到的是如何构建字符串,因为我知道我想要的文件名。如果我使用“打开”&文件名;我打开了对话框。到目前为止,我最好的解决方法是在启动命令之前将FILEDIA设置为0(仍在AutoCAD atm中)。不过我希望我不需要做那么长时间。
我还没有用“\u OPEN”试过。 实际上,DocumentManager。Open()工作正常。。。即使在SDI=1的情况下。
using Autodesk.AutoCAD.Runtime;
using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace CADTutor.Sample.OpenDocInSdiMode
{
public class Commands
{
CommandFlags.Session)]
public void FOO()
{
string dwg = "YourFilePath\\YourFileName.dwg";
acApp.DocumentManager.Open(dwg);
}
}
}
... 关键是CommandFlags。会话属性,这是我在这篇文章中从Tony那里学到的,在谷歌上搜索了一下这个主题。 太棒了!!!
昨天我很早就去参加Melody Gardot的演唱会,错过了这个节目(也很棒,因为我们下周要去巴黎见她)。
我现在已经看到了,而且它很有效。只要多一点逻辑就行了,我就在那里。我可以使用。如果文件存在,则打开方法。SendStringToexecute(“打开”),如果没有。
再次感谢您。(看来我不需要读太多,因为BB为我做了这么好的工作)。
页:
1
[2]