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