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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With