I need to extract a single attribute.

Discussion in 'AutoCAD' started by normanakin, Sep 11, 2003.

  1. normanakin

    normanakin Guest

    I am fairly new in the VBA programming. I am trying to extract a single attribute and the program I have extracts all the attributes in my drawing. Here is the code can someone point me in the right direction.

    Private Sub CommandButton1_Click()
        Dim ACADObject As AcadEntity
        Dim element As Object
        Dim ArrayAttributes As Variant
        Dim TagString As String
        TagString = "BR_ST#"
        Dim I As Integer
        For Each element In ThisDrawing.ModelSpace
        If element.EntityType = 7 Then
        ArrayAttributes = element.GetAttributes
        For I = LBound(ArrayAttributes) To UBound(ArrayAttributes)
        MsgBox "Attribute Text String : " & ArrayAttributes(I).TextString
        UserForm1.Hide
        Next
    End If
        Next
    End Sub



    The attributetag "BR_ST" is the attribute I want to isolate, it is the first one that lists in the message box's. You can email me direct at

    Thanks
     
    normanakin, Sep 11, 2003
    #1
  2. normanakin

    Mark Propst Guest

    is the attribute in a certain block reference? what is the block name?



    that will narrow down the search programatically



    do a filtered selection for the block instead of iterating everything in model space



     



    but in your code as is, you could do something like



        If element.HasAttributes then



           ArrayAttributes = element.GetAttributes
            For I = LBound(ArrayAttributes) To UBound(ArrayAttributes)



                If ArrayAttributes(I).TagString = "tag you want" then
                MsgBox "Attribute Text String : " & ArrayAttributes(I).TextString
                UserForm1.Hide



                End if
            Next



        End if




    "normanakin" <> wrote in message news:...

    I am fairly new in the VBA programming. I am trying to extract a single attribute and the program I have extracts all the attributes in my drawing. Here is the code can someone point me in the right direction.

    Private Sub CommandButton1_Click()
        Dim ACADObject As AcadEntity
        Dim element As Object
        Dim ArrayAttributes As Variant
        Dim TagString As String
        TagString = "BR_ST#"
        Dim I As Integer
        For Each element In ThisDrawing.ModelSpace
        If element.EntityType = 7 Then
        ArrayAttributes = element.GetAttributes
        For I = LBound(ArrayAttributes) To UBound(ArrayAttributes)
        MsgBox "Attribute Text String : " & ArrayAttributes(I).TextString
        UserForm1.Hide
        Next
    End If
        Next
    End Sub



    The attributetag "BR_ST" is the attribute I want to isolate, it is the first one that lists in the message box's. You can email me direct at

    Thanks
     
    Mark Propst, Sep 12, 2003
    #2
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.