Change text

Change text

Anonymous
Not applicable
5,336 Views
22 Replies
Message 1 of 23

Change text

Anonymous
Not applicable

Hi,

You should modify ct.lsp so that it writes a text replacement directly to the command line. Something like trc.lsp. Only this (txtfind "Ĺ" "Š") should be passed directly to the function when running lisp. So automatic text replacement should be done.

0 Likes
Accepted solutions (2)
5,337 Views
22 Replies
Replies (22)
Message 21 of 23

hak_vz
Advisor
Advisor
Accepted solution

@Anonymous 

 

Here is sample for what you had to do, what I told you through private messages and over a phone.

In attachment is a txt file with Croatian alphabet symbols that we read into the drawing and create text entity for

each line of text.Notice that we don't use vla-xxx functions since they are bound to ascii.

 

(defun readandreplace ( / f file_in pt del _text str_subst_all ent
(defun str_subst_all (new old string / search return)
	(setq search (strcat old "*") return "")
	(while (not (eq string ""))
	(if (wcmatch string search)
	  (setq string (substr string (1+ (strlen old))) return (strcat return new))
	  (setq return (strcat return (substr string 1 1)) string (substr string 2))))
	return
)
(setvar 'cmdecho 0)
(setq f (getfiled "Open input file :" (getvar "dwgprefix") "txt" 2))
(setq file_in (open f "r"))
(setq pt (getpoint "\nSelect point to enter text >"))
(setq del (list 0 (* 2 (getvar 'textsize)) 0))
(while (and(setq _text (read-line file_in)))
(setq _text (str_subst_all  "\\U+0160" "Š" _text))
(setq _text (str_subst_all  "\\U+0161" "š" _text))
(setq _text (str_subst_all  "\\U+0110" "Đ" _text))
(setq _text (str_subst_all  "\\U+0111" "đ" _text))
(setq _text (str_subst_all  "\\U+010C" "Č" _text))
(setq _text (str_subst_all  "\\U+010D" "ć" _text))
(setq _text (str_subst_all  "\\U+0106" "Ć" _text))
(setq _text (str_subst_all  "\\U+0107" "ć" _text))
(setq _text (str_subst_all  "\\U+017D" "Ž" _text))
(setq _text (str_subst_all  "\\U+017E" "ž" _text))
(command "_.text" pt "" "" _text)
(setq pt (mapcar '- pt del))
)
(close file_in)
(setvar 'cmdecho 1)
(princ)
)

(readandreplace)

 

 

 

Miljenko Hatlak

EESignature

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.
0 Likes
Message 22 of 23

Anonymous
Not applicable
Thank you. I understood when you told me, but I failed to do so, but now it is clear to me and I succeeded.
I applied this idea you gave me in a simpler way.
Thank you too @pbejse
Message 23 of 23

hak_vz
Advisor
Advisor

I'm glad you have succeded. I'm here if you need any further help.

Miljenko Hatlak

EESignature

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.
0 Likes