Option Explicit
'**********************************************
'********* VARIABLE DECLARATIONS **************
'**********************************************
Dim entX As AcadObject 'Entity object..
Dim attribZ As Variant 'Attributes..
Dim countX As Integer 'Counter..
Dim blnAttributes As Boolean 'Has Attributes?..
Dim Your_variable1, Your_variable2 As String 'Attribute value string..
'**********************************************
'********* VARIABLE DECLARATIONS **************
'**********************************************
' GET THE ATTRIBUTE VALUES..
Sub GET_Attributes()
For Each entX In ThisDrawing.ModelSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
If entX.HasAttributes Then 'Check if object has attributes..
blnAttributes = True ' True if yes..
Exit For
' If no attributes found....
ElseIf Not blnAttributes Then
MsgBox "No attributes found for this block in the drawing..", vbInformation
'GoTo Finished
End If
End If
Next
' Start main loop to get attribute values for the attributes..
For Each entX In ThisDrawing.PaperSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
attribZ = entX.GetAttributes
For countX = LBound(attribZ) To UBound(attribZ)
Select Case attribZ(countX).TagString
'your code for displaying the value o a form or something goes here..
Case "insert an attribute tag here"
Your_variable1 = attribZ(countX).TextString
'your code for displaying the value o a form or something goes here..
Case "insert another attribute tag here"
Your_variable2 = attribZ(countX).TextString
End Select
Next countX
End If
Next ' End main loop..
End Sub
' SET THE ATTRIBUTE VALUES..
Sub SET_Attributes()
For Each entX In ThisDrawing.ModelSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
If entX.HasAttributes Then 'Check if object has attributes..
blnAttributes = True ' True if yes..
Exit For
' If no attributes found....
ElseIf Not blnAttributes Then
MsgBox "No attributes found for this block in the drawing..", vbInformation
'GoTo Finished
End If
End If
Next
' Start main loop to get attribute values for the attributes..
For Each entX In ThisDrawing.PaperSpace
' If the found object is a block..
If entX.EntityName = "AcDbBlockReference" Then
attribZ = entX.GetAttributes
For countX = LBound(attribZ) To UBound(attribZ)
Select Case attribZ(countX).TagString
'your code for updating the value o a form or something goes here..
Case "insert an attribute tag here"
attribZ(countX).TextString = Your_variable1
'your code for updating the value o a form or something goes here..
Case "insert another attribute tag here"
attribZ(countX).TextString = Your_variable2
End Select
Next countX
End If
Next ' End main loop..
End Sub