×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

reading dwg file external to autocad

reading dwg file external to autocad

reading dwg file external to autocad

(OP)
Is there any way i can programmatically read autocad file .dwg and extract information file attributes, blocks, x-ref etc without opening autocad application.

RE: reading dwg file external to autocad

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

DXF is easy.

RE: reading dwg file external to autocad

(OP)
how to change dwg files to dxf in batch.

RE: reading dwg file external to autocad

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

RE: reading dwg file external to autocad

This link also gives a good example of pulling info from a closed drawing file..

http://www.cadmin.com/VBA_for_ADT/ObjectDBX.htm

"Everybody is ignorant, only on different subjects." — Will Rogers

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources