Is there a way to find and/or replace "very" special characters like [carriage return], [backspace] or even [tab mark], considering that the first thing that comes to mind when saying special characters is the standard and extended ASCII only.
Thanks,
@Anonymous wrote:Is there a way to find and/or replace "very" special characters like [carriage return], [backspace] or even [tab mark], ....
Thanks,
Carriage returns and tabs are easy enough to locate in Mtext -- make a piece of it that includes some, and look at the DXF code 1 entry in its entity data, or its TextString VLA Property [backslashes are involved]. You can use (ssget) with a filter to find Mtext that has those in it. Neither of those is applicable in ordinary Text.
But is there such a thing as a backspace character in a completed Text/Mtext entity? You can use backspace in making one, but no "character" representing that survives into the finished product, as far as I know.
AutoCAD has very poor or non-existant support for special characters in the find command. It is complicated by the way that mtext stores special characters. As Kent says, you need to obtain the text string value for the text you are interested in. The only characters that are practical to search for IMO are returns and tabs. Returns are stored only in mtext strings as "\\P". That is a backslash followed by capital P. Tabs are stored as "\t". You could write a function to find or replace these characters.
(vl-string-search pattern string) will find these sequences.
(vl-string-subst new pattern string) will replace the first instance of the pattern in the string
(entmod (subst new old entityinfo)) is the traditional approach to changing entities where new is the new assoc element, ie. '(1 . "New text"). Old is similar. Entityinfo is the list obtained from
(entget ename). Ename can be obtained by (car(entsel))
You may also use vla methods to do the same things by getting and putting the properties.
(vla-get-textstring obj)
(vla-put-textstring obj)
There are different methods and different objects for text, mtext, and attribute objects.