Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding and replacing "very" special characters

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1786 Views, 4 Replies

Finding and replacing "very" special characters

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,

4 REPLIES 4
Message 2 of 5
dbroad
in reply to: Anonymous

Yes, in what context though? LISP, Find command.  Be specific.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 5
Anonymous
in reply to: dbroad

Whatever, the idea is to do it. What do you have in mind?
Message 4 of 5
Kent1Cooper
in reply to: Anonymous


@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.

Kent Cooper, AIA
Message 5 of 5
dbroad
in reply to: Anonymous

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.

Architect, Registered NC, VA, SC, & GA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost