基于块名称、属性值的块计数
本人';我们有一个程序,可以使用不同的选择类型计算不同的块 ;现在,我';我们得到了它,因此它将根据属性标记的值计算块数 ;现在我想将块名添加到混合中,因为一些块可能与其他块具有相同的属性值现在代码中出现了这样的内容…
我想添加块名,这样计数看起来更像这样,以显示哪个块与属性值相关
此处';到目前为止,这是我的代码 ;本人';我已经获得了创建字典的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
嗨,马特,看这条线http://discussion.autodesk.com/thread.jspa?threadID=606029希望能有所帮助;J#039~
字典可能不是最好的容器
在我看来,你可以有Block1 A 3和Block1 B 2。通过解析逗号,你可以用;区块1,A“;3;和“;区块1,B“;2但它';在集合中使用变体数组通常更容易
尺寸Bc(2)
Bc(0)=块。名称:Bc(1)=附件。textstring:Bc(2)=计数现在您按名称为每个blockref建立一个选择集,对该块的Bc进行排序;添加到集合 谢谢大家
这会给我一些思考的东西。
页:
[1]