以编程方式绘制 dwg 文件

发布于 2024-12-23 18:23:59 字数 916 浏览 6 评论 0原文

我编写了一个应用程序来打开和打印 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅浅淡淡 2024-12-30 18:23:59

您的开放代码基本上打开现有图形并将其内容加载到新的文档实例中。由于新文档实例之前不存在,因此它没有保存名称,因此您的绘图消息显示意外的文件名。

我不是 100% 确定这是否有效(我面前没有我的 autoCAD 机器来测试),但您可以尝试将加载代码更改为:

String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;

if(File.Exists(MyDWGFilePath))
{
  dm.Open(MyDWGFilePath, false);
}

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:

String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;

if(File.Exists(MyDWGFilePath))
{
  dm.Open(MyDWGFilePath, false);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文