vba中想显示某个块用什么语句呢?
<p>请教:</p><p>是这样的,我有一个图形,有好多好多块,但里面3个块的名字都叫"AAA",这三个块中有XXX属性,三个块的XXX属性的值分别为1,2,3,我想用vba写个程序,找到块名为"AAA"的且XXX属性值为2的块,然后在autocad图中定位到这个块的位置,也就是把这个块以合适的大小显示在图中间.这其中的显示的块的语句怎么写呢? 前面查找的块的属性值的语句要是能给就更好了</p> <p>补充一下,这三个块中都含有一个矩形的对象,我的目的也就是把那矩形的对角显示出来.</p> <p>用0,"insert"过滤,再获取块的属性值查找对应的属性,然后 zoom</p> <p>zoom某块的语句是什么呢,如果来个zoomall,我那个图中有上千块,根本找不到我要找的那个块</p><p>请教一下,0 insert过滤具体怎么实现呢?</p> <p>不好意思,我可能没有表达清楚,我的意思是我的图中已经有很多很多块参照了,有上千个,上万个,其中有3个块参照名字是“AAA”,他们有属性是XXX,值分别1,2,3,我现在要把那个值为1那个找到,并显示中屏幕中间。</p> <p>Sub tt()<br/> On Error Resume Next<br/> Dim ss As AcadSelectionSet<br/> ThisDrawing.SelectionSets("TlsTest").Delete<br/> Set ss = ThisDrawing.SelectionSets.Add("TlsTest")<br/> <br/> Dim ft(1) As Integer, fd(1)<br/> ft(0) = 0: fd(0) = "insert"<br/> ft(1) = 2: fd(1) = "AAA"<br/> <br/> ss.Select acSelectionSetAll, , , ft, fd<br/> <br/> Dim cblkref As AcadBlockReference<br/> Dim blkref As AcadBlockReference<br/> Dim arr<br/> Dim b As Boolean<br/> b = False<br/> Dim attref As AcadAttributeReference<br/> For Each blkref In ss<br/> arr = blkref.GetAttributes<br/> For Each attref In arr<br/> If attref.TagString = "XXX" Then<br/> If attref.TextString = "1" Then<br/> Set cblkref = blkref<br/> b = True<br/> Exit For<br/> End If<br/> If b Then Exit For<br/> End If<br/> Next attref<br/> Next blkref<br/> <br/> Dim p1, p2<br/> cblkref.GetBoundingBox p1, p2<br/> Application.ZoomWindow p1, p2</p><p>End Sub<br/></p> Sub tt()On Error Resume Next
Dim ss As AcadSelectionSet
ThisDrawing.SelectionSets("TlsTest").Delete
Set ss = ThisDrawing.SelectionSets.Add("TlsTest")
Dim ft(1) As Integer, fd(1)
ft(0) = 0: fd(0) = "insert"
ft(1) = 2: fd(1) = "AAA"
ss.Select acSelectionSetAll, , , ft, fd
Dim cblkref As AcadBlockReference
Dim arr
Dim b As Boolean
b = False
For Each blkref In ss
arr = blkref.GetAttributes
For Each attref In arr
If attref.TagString = "XXX" Then
If attref.TextString = "1" Then
Set cblkref = blkref
b = True
Exit For
End If
End If
Next attref
If b Then Exit For
Next blkref
Dim p1, p2
cblkref.GetBoundingBox p1, p2
Application.ZoomWindow p1, p2
End Sub
页:
[1]