Trying to get attributes

Discussion in 'AutoCAD' started by .o0 0o., Jul 7, 2004.

  1. .o0 0o.

    .o0 0o. Guest

    Why will this not work?

    Dim BlocksColl As AcadBlocks
    Set BlocksColl = ThisDrawing.Blocks
    Dim ExBlock As AcadBlock
    For Each ExBlock In BlocksColl
    If ExBlock.Name = "2002RALEIGHPERMITAPP_ATTS_P1" Then
    Dim BlkAttsP1 As Variant
    BlkAttsP1 = ExBlock.GetAttributes
    End If
    Next
     
    .o0 0o., Jul 7, 2004
    #1
  2. .o0 0o.

    .o0 0o. Guest

    Now it stops on

    For Each ExBlock In BlocksColl

    and ExBlock = Nothing
     
    .o0 0o., Jul 7, 2004
    #2
  3. There are no block references in the Blocks collection; only block
    definitions.

    Either use a filtered selection set to obtain the desired inserts or have
    the user select them manually.
     
    Frank Oquendo, Jul 7, 2004
    #3
  4. .o0 0o.

    .o0 0o. Guest

    Thanks Frank. I had it set up for manual selection. I was trying to
    avoid that though. Am I out of luck?
     
    .o0 0o., Jul 7, 2004
    #4
  5. .o0 0o.

    Matt W Guest

    Will this work for you...??

    Code:
    Option Explicit
    
    Private Sub AttributeSniffer()
    Dim varAtts() As AcadAttributeReference
    Dim objBlock As AcadBlockReference
    Dim dwg As ThisDrawing
    Dim ssSet As AcadSelectionSet
    Dim FilterType(0) As Integer
    Dim FilterData(0) As Variant
    Dim obj As AcadEntity
    Dim i As Integer
    
    Set ssSet = vbdPowerSet("attributesniffer")
    
    FilterType(0) = 0
    FilterData(0) = "Insert"
    
    ssSet.Select acSelectionSetAll, , , FilterType, FilterData
    
    For Each obj In ssSet
    If TypeOf obj Is AcadBlockReference Then
    Set objBlock = obj
    If obj.HasAttributes Then
    varAtts = obj.GetAttributes
    For i = LBound(varAtts) To UBound(varAtts)
    Debug.Print varAtts(i).TagString
    Next i
    End If
    End If
    Next obj
    End Sub
    
    Private Function vbdPowerSet(strName As String) As AcadSelectionSet
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
    
    Set objSelCol = ThisDrawing.SelectionSets
    For Each objSelSet In objSelCol
    If objSelSet.Name = strName Then
    objSelSet.Delete
    Exit For
    End If
    Next
    Set objSelSet = ThisDrawing.SelectionSets.Add(strName)
    Set vbdPowerSet = objSelSet
    End Function
    
    
    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | Thanks Frank. I had it set up for manual selection. I was trying to
    | avoid that though. Am I out of luck?
    |
    | Frank Oquendo wrote:
    |
    | > .o0 0o. wrote:
    | >
    | >>Now it stops on
    | >>
    | >>For Each ExBlock In BlocksColl
    | >>
    | >>and ExBlock = Nothing
    | >
    | >
    | > There are no block references in the Blocks collection; only block
    | > definitions.
    | >
    | > Either use a filtered selection set to obtain the desired inserts or
    have
    | > the user select them manually.
    | >
     
    Matt W, Jul 7, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.