Retrieve Attributes Not In A Block

Discussion in 'AutoCAD' started by ptti, Apr 14, 2004.

  1. ptti

    ptti Guest

    Hello All! I have yet another question. I was wondering how to retrieve attributes that are not placed in a block. I am using the following code to retrieve the attributes out of a block:



    For Each Entity In ThisDrawing.ModelSpace
    If TypeOf Entity Is AcadBlockReference Then
    Set BlockRef = Entity

    If BlockRef.HasAttributes Then
    For Each Block In ThisDrawing.Blocks
    If Block.Name = BlockRef.Name Then
    For Index = 0 To (Block.Count - 1)
    If Block(Index).ObjectName = "AcDbAttributeDefinition" Then
    Set oAttribute = Block(Index)
    array1 = Entity.GetAttributes
    If (Left(oAttribute.PromptString, 3)= "DWN") Then
    DrawnBy = array1(Index).TextString End If
    End If
    Next Index
    End If
    Next Block
    End If
    End If
    Next


    However, I have some drawings in which the drafter had created an attribute that is not within a block. How could I modify my code above to also see if there is any attributes outside of any block. Anyone have any ideas?

    Thanks In Advance.
     
    ptti, Apr 14, 2004
    #1
  2. For Each entity In ThisDrawing.ModelSpace
    If TypeOf entity Is AcadBlockReference Then
    <snip> <snip> <snip>
    ElseIf TypeOf entity Is AcadAttribute Then
    MsgBox "standalone att: " & entity.TextString
    End If
    Next
     
    James Belshan, Apr 14, 2004
    #2
  3. ptti

    ptti Guest

    Thanks a lot. That was what I needed.
     
    ptti, Apr 14, 2004
    #3
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.