This VBA sample shows how to use ObjectDBX to get information from multiple drawings without opening them. You need to have an AutoCAD based application installed though. Here block names are listed but other things can be done with ObjectDBX like making changes to the drawings in different ways. ObjectDBX can also be used with AutoLISP, VB, VB.NET or C#.
Option Explicit Dim objDbx As AxDbDocument ' 2007-06-08 ' By Jimmy Bergmark ' Copyright (C) 2007 JTB World, All Rights Reserved ' Website: www.jtbworld.com ' E-mail: firstname.lastname@example.org ' Runs in AutoCAD 2008 with axdb17enu.tlb (must be referenced) AutoCAD/ObjectDBX Common 17.0 Type Library ' Example of batch for listing all block names on all drawings in a directory. Private Sub ListBlockNames() Set objDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.17") Dim inDir As String Dim elem As Object Dim filenom As String Dim WholeFile As String Dim newHeight As Double inDir = "c:\program files\autocad 2008\sample" filenom = Dir$(inDir & "\*.dwg") Do While filenom <> "" ThisDrawing.Utility.Prompt vbCrLf & "File: " & filenom ThisDrawing.Utility.Prompt vbCrLf & "-----------------" WholeFile = inDir & "\" & filenom objDbx.Open WholeFile For Each elem In objDbx.Blocks If elem.IsXRef = False And Left(elem.Name, 1) <> "*" Then ThisDrawing.Utility.Prompt vbCrLf & elem.Name End If Next Set elem = Nothing filenom = Dir$ ThisDrawing.Utility.Prompt vbCrLf Loop Set objDbx = Nothing End Sub
If you read this using Google reader see the code here.
If you want to manipulate DWG files without having an Autodesk application installed there is the option to use RealDWG.