Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading dwg file external to autocad

Status
Not open for further replies.

agsingh

Aerospace
Sep 28, 2004
8
Is there any way i can programmatically read autocad file .dwg and extract information file attributes, blocks, x-ref etc without opening autocad application.
 
Replies continue below

Recommended for you

You'd have to know the dwg file structure. I don't think AutoCAD has put that in the public domain.

DXF is easy.
 
how to change dwg files to dxf in batch.
 
You need to make a reference to the ObjectDBX library in your project. You can open and browse though a closed drawing with it. We use Excel to check Titleblock attributes in drawings with this. Here is a snippet of code to look at a drawings blocks. It is based on the form I am using, but just look at how it queries the drawing... It uses a open method and then most other AutoCAD properties and methods are available to you. You cannot change and save to a closed drawing though. I hope this helps.
-------------------------------------

Private Sub CmdQueryDwg_Click()
Dim xDoc As Object 'AxDbDocument
Dim dwgFile As String
'''''''''''''''''''''''''''''''''''''''
dwgFile = txtOpenPath.Text

If dwgFile <> "" Then
Set xDoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
xDoc.Open dwgFile

ListBox1.Clear
If OptLayers.Value = True Then
Dim Layer As AcadLayer

For Each Layer In xDoc.Layers
ListBox1.AddItem (Layer.Name)
Next Layer
Else
Dim Block As AcadBlock
For Each Block In xDoc.Blocks
If ChkFilterBlks.Value = False Then
ListBox1.AddItem (Block.Name)
Else
If Left$(Block.Name, 1) <> "*" And _
Left$(Block.Name, 2) <> "A$" Then
ListBox1.AddItem (Block.Name)
End If
End If
Next Block
End If

End If
End Sub

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor