|
Welcome, Guest.
|
||||||
| VBA/COM Interop Step inside and get the VBA help you have been looking for. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Active Member
Join Date: 2007-07
Posts: 84
![]() |
Merry Christmas and a happy new year everybody. Just a little question before the party breaks loose. I'm making a macro that will notify me of all blocknames in a drawing, their occurrence, and a textvalue based on a tagstring. The macro works ok, but the attribute it looks for is fixed. I want to make it dependant on the tagstring ("Type") , and I'm having trouble figuring out how. This part of the code is what I need to change to make it work that way:
Code:
For Each Ent In sset
If TypeOf Ent Is AcadBlockReference Then
Set Blkref = Ent
If Blkref.HasAttributes Then
TextAtts = Blkref.GetAttributes
Attext = TextAtts(1).TextString
End If
End If
BlkNmString = BlkNmString & Blkref.EffectiveName & " - " & Attext & ":"
Attext = ""
Next Ent
Code:
'' For i = LBound (Textatts) To UBound(TextAtts) '' If TextAtts(i).TagString = "Type" Then '' Attext = TextAtts(i).TextString '' Else '' Attext = "" '' End If '' Next i Last edited by darfnuggi : 2009-12-23 at 01:04 PM. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 5,698
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I see no problem other than the usual issues with string comparisons:
If UCase(TextAtts(i).TagString) = "TYPE" Then
__________________
R. Robert Bell Design Technology Manager S P A R L I N G Opinions expressed are mine alone and do not reflect the views of Sparling. |
|
|
|
|
|
#3 |
|
Active Member
Join Date: 2007-07
Posts: 84
![]() |
Thank you very much. This worked well. Another bad in my program was ( Else Attext = " ") because it wiped the result of "Type" if the macro found another blockattribute after that one.
|
|
|
|
|
|
#4 | |
|
All AUGI, all the time
Join Date: 2005-05
Location: Pietari, Venäjä
Posts: 803
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
Code:
For i = LBound (Textatts) To UBound(TextAtts)
If UCase(TextAtts(i).TagString) = "TYPE" Then
Attext = TextAtts(i).TextString
End If
Next i
__________________
"The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." Bertrand Russell |
|
|
|
|
|
|
#5 |
|
Active Member
Join Date: 2007-07
Posts: 84
![]() |
I would leave the "Else" in there. Like this:
Code:
For i = LBound (Textatts) To UBound(TextAtts)
If UCase(TextAtts(i).TagString) = "TYPE" Then
Attext = TextAtts(i).TextString
Else
End If
Next i
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: 2001-08
Location: Seattle WA US
Posts: 5,698
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
What makes you think that?
__________________
R. Robert Bell Design Technology Manager S P A R L I N G Opinions expressed are mine alone and do not reflect the views of Sparling. |
|
|
|
|
|
#7 |
|
Active Member
Join Date: 2007-07
Posts: 84
![]() |
You are right, I shouldn't have thought that. I assumed the program wouldn't know what to do if "TYPE" didn't occur in the block at all, but it just ignores those attributes.
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Anyone know how to get (getstring T) to work? | rpowell | AutoLISP | 4 | 2007-11-07 06:02 PM |