I need to extract a single attribute.

I need to extract a single attribute.

Anonymous
Not applicable
309 Views
2 Replies
Message 1 of 3

I need to extract a single attribute.

Anonymous
Not applicable
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 [email protected]

Thanks
0 Likes
310 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
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


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
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
[email protected]

Thanks

0 Likes
Message 3 of 3

Anonymous
Not applicable
Yes my attribute is in the block called "BlockbusterBorder" Your code addition works out well. My next step is to put the text in Textbox1 which is easy. After that I am compiling a master list I might need help on but I want to try first on my own. Thanks for the info.
0 Likes