暖暖阳光 发表于 2008-1-27 22:36:00

vba中想显示某个块用什么语句呢?

<p>请教:</p><p>是这样的,我有一个图形,有好多好多块,但里面3个块的名字都叫"AAA",这三个块中有XXX属性,三个块的XXX属性的值分别为1,2,3,我想用vba写个程序,找到块名为"AAA"的且XXX属性值为2的块,然后在autocad图中定位到这个块的位置,也就是把这个块以合适的大小显示在图中间.这其中的显示的块的语句怎么写呢? 前面查找的块的属性值的语句要是能给就更好了</p>

暖暖阳光 发表于 2008-1-27 23:25:00

<p>补充一下,这三个块中都含有一个矩形的对象,我的目的也就是把那矩形的对角显示出来.</p>

雪山飞狐_lzh 发表于 2008-1-28 12:04:00

<p>用0,"insert"过滤,再获取块的属性值查找对应的属性,然后 zoom</p>

暖暖阳光 发表于 2008-1-28 12:20:00

<p>zoom某块的语句是什么呢,如果来个zoomall,我那个图中有上千块,根本找不到我要找的那个块</p><p>请教一下,0 insert过滤具体怎么实现呢?</p>

暖暖阳光 发表于 2008-1-28 12:25:00

<p>不好意思,我可能没有表达清楚,我的意思是我的图中已经有很多很多块参照了,有上千个,上万个,其中有3个块参照名字是“AAA”,他们有属性是XXX,值分别1,2,3,我现在要把那个值为1那个找到,并显示中屏幕中间。</p>

雪山飞狐_lzh 发表于 2008-1-30 12:29:00

<p>Sub tt()<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; Dim ss As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SelectionSets("TlsTest").Delete<br/>&nbsp;&nbsp;&nbsp; Set ss = ThisDrawing.SelectionSets.Add("TlsTest")<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim ft(1) As Integer, fd(1)<br/>&nbsp;&nbsp;&nbsp; ft(0) = 0: fd(0) = "insert"<br/>&nbsp;&nbsp;&nbsp; ft(1) = 2: fd(1) = "AAA"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ss.Select acSelectionSetAll, , , ft, fd<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim cblkref As AcadBlockReference<br/>&nbsp;&nbsp;&nbsp; Dim blkref As AcadBlockReference<br/>&nbsp;&nbsp;&nbsp; Dim arr<br/>&nbsp;&nbsp;&nbsp; Dim b As Boolean<br/>&nbsp;&nbsp;&nbsp; b = False<br/>&nbsp;&nbsp;&nbsp; Dim attref As AcadAttributeReference<br/>&nbsp;&nbsp;&nbsp; For Each blkref In ss<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr = blkref.GetAttributes<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each attref In arr<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If attref.TagString = "XXX" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If attref.TextString = "1" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set cblkref = blkref<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit For<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If b Then Exit For<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next attref<br/>&nbsp;&nbsp;&nbsp; Next blkref<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim p1, p2<br/>&nbsp;&nbsp;&nbsp; cblkref.GetBoundingBox p1, p2<br/>&nbsp;&nbsp;&nbsp; Application.ZoomWindow p1, p2</p><p>End Sub<br/></p>

雪山飞狐_lzh 发表于 2008-1-30 12:32:00

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]
查看完整版本: vba中想显示某个块用什么语句呢?