我有一个程序,用不同的选择类型来计算不同的块。现在,我已经得到了它,这样它将根据属性标签的值来计算块数。现在,我想将块名添加到组合中,因为一些块可能与其他块具有相同的属性值。
所以现在代码抛出了类似这样的内容...
我想添加块名,使计数看起来更像这样,以显示哪个块与属性值相关联。
这是我目前为止的代码。我有一个创建字典的MS脚本运行时的参考。
- Private Sub GetAttributeCount()
- Dim objAttKeys As Variant
- Dim objAttItems As Variant
- Dim objAttDict As Dictionary
- Dim varAtts() As AcadAttributeReference
- Dim objBlock As AcadBlockReference
- Dim obj As AcadEntity
- Dim i, x As Integer
-
- Set objAttDict = New Dictionary
-
- x = 1
- For Each obj In SSet
- Set objBlock = obj
- If obj.HasAttributes Then
- varAtts = obj.GetAttributes
- For i = LBound(varAtts) To UBound(varAtts)
- If UCase$(varAtts(i).TagString) = "DATATYPE" Then
- If objAttDict.Exists(varAtts(i).TextString) = False Then
- objAttDict.Add varAtts(i).TextString, 1
- Else
- objAttDict.item(varAtts(i).TextString) = objAttDict.item(varAtts(i).TextString) + 1
- End If
- End If
- On Error GoTo 0
- Next i
- End If
- Next obj
-
- i = 0
-
- objAttKeys = objAttDict.Keys
- objAttItems = objAttDict.Items
- For x = 0 To UBound(objAttKeys)
- Debug.Print objAttKeys(x) & vbTab & objAttItems(x)
- i = i + objAttItems(x)
- Next
- End Sub
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |