使用 Access 2007 中的 VBA 在 AutoCAD (dwg) 文件中搜索
我有数百个 DWG、AutoCAD 文件,我想将它们搜索并编录到 MS Access 数据库中。
基本上,我想搜索 DWG 并提取标题框中的任何描述以及日期,并将所有内容转移到 Access 中,使其成为可搜索的目录。
例如,我有一个文件名为 T-25682.DWG,其标题为 Machine Spacer,创建于 01/20/2010。
我将从 DWG 文件中提取该信息并将其插入到 Access 数据库中,如下所示:
== ID == == DESCRIPTION == == CREATED ON == == FILENAME ==
1 Machine Spacer 01/20/2010 T-25682.dwg
我该如何处理并解决这个问题?是否有可以与 Access 一起使用的 AutoCAD 库?如何在 DWG 文件中搜索?
I have hundreds of DWG, AutoCAD files that I would like search and catalog into an MS Access Database.
Basically, I would like to search the DWG's and extract whatever description is in the Title box as well as the Date and bring everything over to Access making it a searchable catalog.
For example, I have a file name T-25682.DWG, which is titled Machine Spacer and created 01/20/2010.
I would extract that info form the DWG file and insert it into the Access database as such:
== ID == == DESCRIPTION == == CREATED ON == == FILENAME ==
1 Machine Spacer 01/20/2010 T-25682.dwg
How can I approach and solve this problem? Is there an AutoCAD library I can use with Access? How can I search in a DWG file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会完全避免使用 VBA,AutoLISP 可以轻松完成这项工作。具体方法如下:
在 AutoLISP 文件内创建“数据提取和写入 Access”功能。免费提供的 ADOLisp 库将使写入 Access 变得轻而易举,如果失败,或者您无法做到这一点,您始终可以只写入 csv 文件...
一旦您能够为单个文件执行此操作dwg 文件,创建一个脚本(使用任何可以复制和打开文件的工具,AutoLisp 也可以)来执行以下操作:
注意:
AutoLisp 真的非常简单,如需学习帮助,请访问 AutoLISP 初学者教程。
有关提出问题和搜索以前回答的问题中的代码片段的最佳位置,请参阅 Visual LISP、AutoLISP 和常规自定义。
I would avoid VBA altogether, AutoLISP can do the job for with far less pain. Here's how:
Create the "data extraction and writing to Access" functionality inside an AutoLISP file. The freely available ADOLisp library will make it a breeze writing to Access, if that fails, or you aren't able to do it you can always just write to a csv file...
Once you're able to do that for a single dwg file, create a script (using anything that can copy and open files, AutoLisp works too) to do the following:
Notes:
AutoLisp is really really easy, for help with learning go to AutoLISP Beginners' Tutorials.
For the best place to ask questions and search for code snippets from previous answered questions, see Visual LISP, AutoLISP and General Customization.
如果您有完整版本的 AutoCAD,您可以尝试数据提取向导。这对于属性块来说非常有效。如果这不好,最好的尝试地方是 Swamp 或 AutoCAD 论坛或 AUGI。
VBA 在 AutoCAD 的最后 3 个版本中已被弃用,取而代之的是 .NET API,仅供参考
+edit+
查看有关 AutoCAD 外部数据库连接的(免费)章节< /a>.
If you have a full version of AutoCAD you can try the Data Extraction Wizard. This works quite well for attributed blocks. If this is no good, the best places to try are the Swamp or the AutoCAD forums or AUGI.
VBA is deprecated in the last 3 versions of AutoCAD in favour of the .NET API, FYI
+edit+
Have a look at this (free) chapter on AutoCAD external database connectivity.