yiyaozjk 发表于 2014-4-28 20:43
可以呀,定义成块后,只要能找到就可以。。。
楼上的高手能否出手?给一点代码
我算不上是高手,也是初学一二,最近明经论坛的大神似乎都不在家。
下面是我写的一个供你参考,并附上你的图纸:
- '我在你的图上创建了3种属性快,名称分别为:
- '“福瓶”——方框,“花瓶”——圆,“青花缸”——圆锥
- '现在以“福瓶”为例子
- Private Sub Demo()
-
- '先创建选择集,为了可以多次创建选择集应该删掉原来存在的选择集
- Dim i As Integer
- Dim SSet As AcadSelectionSet
- For i = 0 To ThisDrawing.SelectionSets.Count - 1
- If StrComp("X_SSET", ThisDrawing.SelectionSets.Item(i).Name, vbTextCompare) = 0 Then
- ThisDrawing.SelectionSets.Item(i).Delete
- Exit For
- End If
- Next
- Set SSet = ThisDrawing.SelectionSets.Add("X_SSET")
- '定义过滤表,做到精确选取
- Dim fType(2) As Integer
- Dim fDate(2) As Variant
- fType(0) = 0: fDate(0) = "INSERT"
- fType(1) = 2: fDate(1) = "福瓶"
- fType(2) = 66: fDate(2) = 1
- '到图纸中选择
- SSet.SelectOnScreen fType, fDate
-
- '遍历内容
- Dim Ent As AcadBlockReference
- Dim AttArry As Variant
- For i = 0 To SSet.Count - 1
- Set Ent = SSet.Item(i)
- AttArry = Ent.GetAttributes
- '应为我只定义一个属性,所以AttArry下标为0即可
- ThisDrawing.Utility.Prompt vbCrLf & "第 " & i + 1 & " 个属性块的值为:" & AttArry(0).TextString
- Next
-
- End Sub
|