Duplicate Attribute Tag

Duplicate Attribute Tag

Anonymous
Not applicable
349 Views
3 Replies
Message 1 of 4

Duplicate Attribute Tag

Anonymous
Not applicable
I am extracting TextString and Handle from attributes based on the TagString
however, some of the blocks have duplicate TagStrings which only differ by
PromptString. Since PromptString is not a property of the Block Reference
how can I programmatically isolate the duplicate tags.

Cheers, John.
0 Likes
350 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Place the AttDefs' prompt strings of the Block into an array. The index of
this array will match the index of the array obtained with
oBlkRef.GetAttributes

So vAttDefs(3) will be the PrompString for the Att at vAtts(3)

HTH,
Jeff

"John McDowell" wrote in message
news:5210238@discussion.autodesk.com...
I am extracting TextString and Handle from attributes based on the TagString
however, some of the blocks have duplicate TagStrings which only differ by
PromptString. Since PromptString is not a property of the Block Reference
how can I programmatically isolate the duplicate tags.

Cheers, John.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks Jeff, that should do the trick.

Cheers, John.

"Jeff Mishler" wrote in message
news:5210241@discussion.autodesk.com...
Place the AttDefs' prompt strings of the Block into an array. The index of
this array will match the index of the array obtained with
oBlkRef.GetAttributes

So vAttDefs(3) will be the PrompString for the Att at vAtts(3)

HTH,
Jeff

"John McDowell" wrote in message
news:5210238@discussion.autodesk.com...
I am extracting TextString and Handle from attributes based on the TagString
however, some of the blocks have duplicate TagStrings which only differ by
PromptString. Since PromptString is not a property of the Block Reference
how can I programmatically isolate the duplicate tags.

Cheers, John.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Here is another way
[code]
Option Explicit
Sub ChangeDupes()
Dim blkRef As AcadBlockReference
Dim attObj As AcadAttributeReference
Dim varPt As Variant
Dim blkDef As AcadBlock
Dim itmObj As AcadObject
Dim blkName, attVal As String
Dim aTag, sTag, sPrompt As String
Dim i, j As Integer
Dim tmpArr(1) As String
Dim dataColl As New Collection

On Error Resume Next
'@' get the block reference
ThisDrawing.Utility.GetEntity blkRef, varPt, "Select block reference"
If blkRef Is Nothing Then
MsgBox "Nothing selected" & vbCrLf & "try again"
Exit Sub
End If
blkName = blkRef.Name
Set blkDef = ThisDrawing.Blocks.Item(blkName)
aTag = UCase(InputBox("Enter a tag name" & vbCrLf & _
"(case-non-sensitive) : "))
On Error GoTo ErrCatch:
'@' fill collection with promps and tags
For Each itmObj In blkDef
If itmObj.ObjectName = "AcDbAttributeDefinition" Then
If itmObj.TagString = aTag Then
sPrompt = itmObj.PromptString
sTag = itmObj.TagString
tmpArr(0) = sPrompt
tmpArr(1) = sTag
dataColl.Add tmpArr
Erase tmpArr
End If
End If
Next

'@' change attribute values
Dim attArr As Variant
Dim colArr As Variant
attArr = blkRef.GetAttributes
j = 1
For i = 0 To UBound(attArr)
Set attObj = attArr(i)
If attObj.TagString = aTag Then
colArr = dataColl.Item(j)

'@' Loop trough collection
Select Case colArr(0)
Case "First prompt"
attObj.TextString = "Value #1"
Case "Second prompt"
attObj.TextString = "Value #2"
Case "Third prompt"
attObj.TextString = "Value #3"
Case "Fourth prompt"
attObj.TextString = "Value #4"
End Select

j = j + 1
End If
Next

'@' release collection
Dim unitArr As Variant
For Each unitArr In dataColl
dataColl.Remove 1
Next
Set dataColl = Nothing

ErrCatch:
MsgBox Err.Description
End Sub
[/code]

Fatty

~'J'~
0 Likes