Thursday, September 9, 2010
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > VBA/COM Interop
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

VBA/COM Interop Step inside and get the VBA help you have been looking for.

Reply
 
Thread Tools Display Modes
Old 2009-12-23, 11:41 AM   #1
darfnuggi
Active Member
 
Join Date: 2007-07
Posts: 84
darfnuggi is infamous around these parts
Smile Attribute textstrings by Tagstring

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
I tried the following but it also selects the second attribute, and ignores the tagstring (wich should be the criterium for getting the textstring).

Code:
''                For i = LBound (Textatts)  To UBound(TextAtts)
''                If TextAtts(i).TagString = "Type" Then
''                        Attext = TextAtts(i).TextString
''                        Else
''                        Attext = ""
''                End If
''                Next i
Inspiration & help would be great. I've run out of ideas.

Last edited by darfnuggi : 2009-12-23 at 01:04 PM.
darfnuggi is offline   Reply With Quote
Old 2009-12-23, 04:56 PM   #2
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 5,698
RobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the stars
Default Re: Attribute textstrings by Tagstring

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.
RobertB is offline   Reply With Quote
Old 2009-12-24, 07:19 AM   #3
darfnuggi
Active Member
 
Join Date: 2007-07
Posts: 84
darfnuggi is infamous around these parts
Default Re: Attribute textstrings by Tagstring

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.
darfnuggi is offline   Reply With Quote
Old 2009-12-24, 09:54 AM   #4
fixo
All AUGI, all the time
 
fixo's Avatar
 
Join Date: 2005-05
Location: Pietari, Venäjä
Posts: 803
fixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moonfixo is reaching for the moon
Default Re: Attribute textstrings by Tagstring

Quote:
Originally Posted by darfnuggi View Post
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.
Change on this code block
Code:
 
               For i = LBound (Textatts)  To UBound(TextAtts)
                If UCase(TextAtts(i).TagString) = "TYPE" Then
                       Attext = TextAtts(i).TextString  
             End If
             Next i
~'J'~
__________________
"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
fixo is offline   Reply With Quote
Old 2010-01-05, 09:37 AM   #5
darfnuggi
Active Member
 
Join Date: 2007-07
Posts: 84
darfnuggi is infamous around these parts
Default Re: Attribute textstrings by Tagstring

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
Without the "Else" the program stops when "TYPE" isn't found.
darfnuggi is offline   Reply With Quote
Old 2010-01-06, 12:41 AM   #6
RobertB
Administrator
 
RobertB's Avatar
 
Join Date: 2001-08
Location: Seattle WA US
Posts: 5,698
RobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the starsRobertB has reached the stars
Default Re: Attribute textstrings by Tagstring

Quote:
Originally Posted by darfnuggi View Post
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
Without the "Else" the program stops when "TYPE" isn't found.
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.
RobertB is offline   Reply With Quote
Old 2010-01-07, 10:29 AM   #7
darfnuggi
Active Member
 
Join Date: 2007-07
Posts: 84
darfnuggi is infamous around these parts
Red face Re: Attribute textstrings by Tagstring

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.
darfnuggi is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > VBA/COM Interop

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

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


All times are GMT +1. The time now is 08:31 AM.