TagSTring, TextString, PrompString?

TagSTring, TextString, PrompString?

Anonymous
Not applicable
797 Views
1 Reply
Message 1 of 2

TagSTring, TextString, PrompString?

Anonymous
Not applicable
Hi,

When I make a select from all blocks in a drawing, I want to get the PromptString from an attribute, I'm using VB.NET which is very different from standard VB. The TagString and Textstring work ok, but I need the promptstring!

Here's my SUB...

Public Sub testIt()
Dim ss As AutoCAD.AcadSelectionSet
ss = myAutoCadApp.ActiveDocument.SelectionSets.Add("test")
Dim FilterType(0) As Short
Dim FilterCode(0) As Object
FilterType(0) = 2
FilterCode(0) = "WTBHFD"
ss.Select(AutoCAD.AcSelect.acSelectionSetAll, , , FilterType, FilterCode)
Dim a As AutoCAD.AcadBlockReference
Dim att As AutoCAD.AcadAttribute
Dim atts As Object
Dim i As Integer
Dim strAttributes As String
i = 0
For Each a In ss
atts = a.GetAttributes
For i = LBound(atts) To UBound(atts)
strAttributes = strAttributes & " Tag: " & atts(i).TagString & _
" Value: " & atts(i).textString & vbNewLine
Next
TextBox1.Text = strAttributes
Next
End Sub

The Problem is that the PromptString is in an AcadAttribute type, don't have it, because atts is an object..

Is this possible?
0 Likes
798 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
The objects in the 'atts' array are attribute
references, AcadAttributeReference. This class does not have the PromptString
property.

 

To get the PromptString you need to get the
attribute definition, AcadAttribute, from the block definition,
AcadBlock.

 

You get the block definition from the block
collection on the AcadDocument (ThisDrawing) based on the block reference
name.

 

Loop the entities in the block definition to find
the attribute definition matching the attribute reference.

 

I've never had use for this in VB/VBA, so there
might be some trick to make it easier that I'm not aware of. I have however
done this several times with VLisp.

 

I hope this helps.

 

--
Rune Wold
Take the dog for a walk to reply

 

--


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,

When I make a select from all blocks in a drawing, I want to get the
PromptString from an attribute, I'm using VB.NET which is very different from
standard VB. The TagString and Textstring work ok, but I need the
promptstring!

Here's my SUB...

Public Sub testIt()
        Dim
ss As AutoCAD.AcadSelectionSet

        ss =
myAutoCadApp.ActiveDocument.SelectionSets.Add("test")

        Dim FilterType(0) As Short

        Dim FilterCode(0) As
Object
        FilterType(0) = 2

        FilterCode(0) = "WTBHFD"

        ss.Select(AutoCAD.AcSelect.acSelectionSetAll,
, , FilterType, FilterCode)

        Dim a As
AutoCAD.AcadBlockReference

        Dim att As
AutoCAD.AcadAttribute
        Dim
atts As Object
        Dim i As
Integer
        Dim strAttributes
As String
        i = 0

        For Each a In ss

            atts
= a.GetAttributes

            For
i = LBound(atts) To UBound(atts)

                strAttributes
= strAttributes & " Tag: " & atts(i).TagString & _

                                               "
Value: " & atts(i).textString & vbNewLine

            Next

            TextBox1.Text
= strAttributes
        Next

    End Sub

The Problem is that the PromptString is in an AcadAttribute type, don't
have it, because atts is an object..

Is this possible?

0 Likes