Hello to all,
I am trying to catch block attributes from the attached drawing and to show them in listed in the msgbox.
Here is a code that I have tried but I am not getting any message box after loading form and recognizing opened dwg:
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'AutoCAD app
Dim acadApp As AcadApplication
acadApp = GetObject(, "AutoCAD.Application")
'Active doc
Dim dbxDoc As Object
dbxDoc = acadApp.ActiveDocument
acadApp.Visible = True
Dim I As Integer
Dim strAttributes As String
Dim varAttributes As Object
Dim entity As Object
'Try to catch attributes from the opened dwg
For Each entity In dbxDoc.PaperSpace
If TypeOf entity Is AcadBlockReference Then
If entity.HasAttributeDefinitions = True Then
varAttributes = entity.GetAttributes
strAttributes = ""
For I = LBound(varAttributes) To UBound(varAttributes)
'Return catched blocks with their attributes
MsgBox("BLOCKNAME: " & entity.name & vbCr _
& "TAG : " & varAttributes(I).TagString & vbCr _
& "VALUE : " & varAttributes(I).TextString)
Next
Else
End If
End If
Next entity
End Sub
I would appreciate if someone can help me cause I am struggling few days with this.