以编程方式绘制 dwg 文件
我编写了一个应用程序来打开和打印 dwg 文件。绘图过程工作正常;但是,当我查看“绘图和发布详细信息”窗口时,我发现“文件”属性设置为
而不是我的 dwg 文件名。
我的意思是这样的:
工作表:UnsavedDwg_2-Model - 已绘制
文件:<未保存的绘图>> 类别名称:> 页面设置:> 设备名称:\\服务器\MyPrinterName> 绘图文件路径:> 纸张尺寸 : Letter
我的错误是什么?!!!
注意:我使用了 DocumentCollection
类的 Open
方法来打开我的 dwg 文件和 此代码将打开的 dwg 文件绘制到打印机。
我打开 dwg 文件的代码:
String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;
Document doc = null;
if(File.Exists(MyDWGFilePath))
{
doc = dm.Open(MyDWGFilePath, false);
Application.DocumentManager.MdiActiveDocument = doc;
}
I have written an application to open and print a dwg file. The plotting process is working correctly; however, when I looked at the Plot and Publish Details window, I saw that the File property is set to <UnSaved Drawing>
instead of my dwg file name.
I mean something like this :
Sheet :UnsavedDwg_2-Model - Plotted
File : <UnSaved Drawing>> Category name :> Page setup :> Device name : \\server\MyPrinterName> Plot file path :> Paper size : Letter
what is my mistake?!!!
Note : I have used the Open
method of DocumentCollection
class to open my dwg file and this code to plotting the opened dwg file to printer.
My code to open dwg file :
String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;
Document doc = null;
if(File.Exists(MyDWGFilePath))
{
doc = dm.Open(MyDWGFilePath, false);
Application.DocumentManager.MdiActiveDocument = doc;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的开放代码基本上打开现有图形并将其内容加载到新的文档实例中。由于新文档实例之前不存在,因此它没有保存名称,因此您的绘图消息显示意外的文件名。
我不是 100% 确定这是否有效(我面前没有我的 autoCAD 机器来测试),但您可以尝试将加载代码更改为:
Your open code basically opens the existing drawing and loads the contents of it it into a new document instance. Since the new document instance did not exist before, it has no save name and hence your plot message shows the unexpected filename.
I'm not 100% sure if this will work (I don't have my autoCAD machine in front of me to test), but you can try changing your loading code to: