SelectionSet.Item(1).TextString

SelectionSet.Item(1).TextString

geotis
Participant Participant
1,259 Views
2 Replies
Message 1 of 3

SelectionSet.Item(1).TextString

geotis
Participant
Participant

I have one text object in my selection set.  I'm trying to use the method shown in the title to obtain the text string.  The Locals Window correctly reports the text string in Item1.  However, I get the error message "Invalid argument index in Item".

 

Can someone tell me the proper syntax to use for this?

 

Thanks

0 Likes
1,260 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor

Cast the item to an AcadText entity. Then use it's TextString property. You should also check the ss for a count > 0, and test the item to be sure its a text ent.

 

Dim oTextEnt As AcadText

Set oTextEnt = ss.Item(1)

MsgBox "The text says: " & oTextEnt.TextString

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 3

norman.yuan
Mentor
Mentor

@geotis wrote:

I have one text object in my selection set. 


It is not very clear whether the SelectionSet only have one item and the item is a Text object, or the SelectionSet have multiple objects and one of it (Item(1), the SECOND one in the selectionset) is Text object? Your code ONLY works in the the latter case.

 

If the selectionset ONLY has one object, then the index in the Item(index) should be 0, not 1.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes