Type block
    blockName As String
    handel As String
End TypeType line
    lineName As String
    handel As String
End TypeSub yjjc()
    Dim ent As AcadEntity
    Dim arrblock() As block
    ReDim arrblock(3000)
    
    Dim arrline() As line
    ReDim arrline(3000)
    Dim cntb As Long
    cntb = 0
    Dim cntl As Long
    cntl = 0
    For Each ent In ThisDrawing.ModelSpace
       Select Case ent.ObjectName
            Case "AcDbBlockReference"
               arrblock(cntb).blockName = getXdataByText(ent, "点号")
               arrblock(cntb).handel = ent.handle
               cntb = cntb + 1
               If cntb = 3000 Then
                    ReDim Preserve arrblock(10000)
               End If
            Case "AcDbPolyline"
               arrline(cntl).lineName = getXdataByTextForLine(ent, "点号")
               arrline(cntl).handel = ent.handle
               cntl = cntl + 1
               If cntl = 3000 Then
                    ReDim Preserve arrline(10000)
               End If
            End Select            
    Next
End Sub
现在2个TYPE中都有 blockName 为"DX1","DX2","DX3",lineName 为"DX1" ,请问怎么遍历得到DX2和DX3 存到数组里...

解决方案 »

  1.   

    type是语句,不是对象,哪有属性?只能是元素
      

  2.   


    Dim diffentarr() As String
        ReDim diffentarr(3000)
        Dim cntd As Long
        cntd = 0
        For i = 0 To cntb
           For j = 0 To cntl
              If arrblock(i).blockName <> "" Then
                  If arrblock(i).blockName = arrline(j).lineName Then
                     diffentarr(cntd) = arrblock(i).blockName
                     cntd = cntd + 1
                     Exit For
                  End If
              End If
           Next j
        Next i
    哈哈  我这样解决的...把不同的存到diffentarr()里了...