嗨,我需要打开一个存储在C:\Temp文件夹中的绘图文件。我尝试了以下代码
public void launchacad(string pth) //pth is the path to the .DWG file
{
const string progID = "AutoCAD.Application.19.1";
const string exePath = @"C:\Program Files\Autodesk\AutoCAD 2014\acad.exe";
AcadApplication acApp = null;
try
{
acApp =
(AcadApplication)Marshal.GetActiveObject(progID);
}
catch { }
if (acApp != null)
{
MessageBox.Show("An instance of AutoCAD is already running.");
}
else
{
try
{
ProcessStartInfo psi =new ProcessStartInfo(exePath);
psi.WorkingDirectory = @"C:\Temp";
psi.Arguments = pth;
Process pr = Process.Start(psi);
pr.WaitForInputIdle();
while (acApp == null)
{
try
{
acApp =(AcadApplication)Marshal.GetActiveObject(progID);
}
catch
{
Application.DoEvents();
}
}
}
catch (Exception ex)
{
MessageBox.Show(
"Cannot create or attach to AutoCAD object: "
+ ex.Message
);
}
}
if (acApp != null)
{
acApp.Visible = true;
acApp.ActiveDocument.SendCommand("_MYCOMMAND ");
}
}
但是,Autocad一启动,就会弹出一条错误消息,当我使用Cannot find the specified drawing.
并键入CMD.exe时,它会说是CMD.exe。
"C:\Program Files\Autodesk\AutoCAD 2014\acad.exe" "C:\Temp\41 Stabd.dwg" It opens Autocad with the file(41 Stand.dwg) open.
我不明白我在哪里出了差错。有人能帮帮我吗。
发布于 2014-11-03 08:31:54
如果绘图仍然存在问题,则继续执行下一组步骤。
这些操作可以按任何顺序进行,但已按Autodesk建议的最合理顺序列出。可以在每一步之后检查该文件。如果事情恢复正常,就没有必要继续执行其余的步骤。打开一个空白的DWG并在命令行中键入RECOVER。浏览到有问题的文件,让AutoCAD有机会恢复该文件.
<还原布局选项卡:
解剖图纸。在文件的副本中,使用QSELECT来选择不同的对象类型,然后删除它们以查看是否修复了文件中的错误。每次删除后,请全部清除。最后,您应该删除问题元素,然后可以选择将它们排除在外,从另一个文件中再次复制它们,重新创建它们,或者进一步对单个项目进行故障排除,以准确地确定问题所在。这个整个过程的一个快速开始就是删除绘图中的所有内容,然后测试它。这将很快告诉您问题是否与绘图对象有关,还是绘图数据库的一部分。
https://stackoverflow.com/questions/23490165
复制相似问题