I'm trying to use automation of Autocad through MSAccess to get attributes out of a cad drawing. The code worked fine when I typed it up in Autocad, but when I moved it over to MSAccess it keeps crashing Access. Yes, I included the reference file.
Here's what it looks like in Autocad:
Code:
Dim blkTitle As AcadBlockReference
For Each oEnt In ThisDrawing.ModelSpace
If oEnt.EntityType = acBlockReference Then
If oEnt.HasAttributes Then
If oEnt.Name = "TITLE" Then
Set blkTitle = oEnt
If blkTitle.HasAttributes Then
aryAttributes = blkTitle.GetAttributes
MsgBox aryAttributes(0).TextString
End If
End If
End If
End If
Next oEnt
Here it is in Access:
Code:
Dim oACAD As AutoCAD.AcadApplication
Dim oDoc As AutoCAD.AcadDocument
Set oACAD = New AutoCAD.AcadApplication 'Start automation of Acad
Set oDoc = oACAD.Documents.Open(FilepathInput, False)
Dim blkTitle As AcadBlockReference
For Each oEnt In oDoc.ModelSpace
If oEnt.EntityType = acBlockReference Then
If oEnt.HasAttributes Then
If oEnt.Name = "TITLE" Then
Set blkTitle = oEnt
If blkTitle.HasAttributes Then
aryAttributes = blkTitle.GetAttributes
MsgBox aryAttributes(0).TextString 'Crashes HERE
End If
End If
End If
End If
Next oEnt
I was wondering if anyone might have any insight into why it would be crashing? I don't get any error messages or anything, just a Send Error Report dialog. Could it have to do with the fact the objects in the Array are typed AcadAttributeReference? Thanks for any help you can provide.
Ps. Running Autocad 2008
Bookmarks