Sub setAttributes()
'变量声明
Dim modelSpac As AcadModelSpace
Dim objAttributes As Variant
Dim pipeLineValue As Variant
Dim indexValue As String
Dim objNum As Integer
'创建模型空间
Set modelSpac = ThisDrawing.ModelSpace
' 获取实例,并判断需要的实例
For Each ent In modelSpac
Debug.Print ent.Name
If TypeOf ent Is AcadBlockReference And ent.HasAttributes() And ent.Name = "管线特性块" Then
objAttributes = ent.getAttributes
indexValue = objAttributes(0).TextString
’修改块属性值
pipeLineValue = getLineValue(indexValue)
If UBound(objAttributes) = UBound(pipeLineValue) Then
For n = 0 To UBound(objAttributes)
Debug.Print objAttRef.TagString
objAttributes(n).TextString = pipeLineValue(n)
Next
Else
Debug.Print "属性对:数量不一致"
End If
End If
Next
End Sub
Function getLineValue(LineNo) As String()
Dim LineValue(0 To 3) As String
LineValue(0) = "2"
LineValue(1) = "a"
LineValue(2) = "我的"
LineValue(3) = "ad"
getLineValue = LineValue()
End Function