Code Red > AutoLISP (Vanilla / Visual)

Help including mtext in change text routine

(1/6) > >>

notredave:
All,

Good afternoon. Could someone please look at attached routine and be able to modify it to include mtext. I love typing ct and picking text to change what I need. It would be nice to select regular and mtext at the same time as drawings have mixed text formats. I would rather use this opposed to using "FIND" to replace mtext characters. Thank you very much in advance.

David

BIGAL:
A full rewrite would be easier there is  (vl-string-subst newstr oldstr string 1) which swaps new for old. The ssget should be (ssget (list (cons 0 "*text"))) so only text or mtext is found. Multi getvals.lsp is a library routine you are welcome to use.


--- Code: ---; Change part of text
; By Alan H info@alanh.com.au july 2019
; will not find hidden characters in middle of mtext
(vl-load-com)
(defun c:chgahtext  ( / ans ss told tnew tobj x)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Old => New" "Old text " 10 9 "-" "New text"10 9 "_" )))
(setq told (nth 0 ans))
(setq tnew (nth 1 ans))
(setq ss (ssget (list (cons 0 "*text"))))
(repeat (setq x (sslength ss))
(setq tobj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(vla-put-textstring tobj (vl-string-subst tnew told (vla-get-textstring  tobj )))
)
(princ)
)
(alert "To run again type chgahtext")
(c:chgahtext)

--- End code ---

notredave:
BIGAL,

Thank you very much for the response and I tried your routine and it does work but backwards to what I'm used to. With mine, I type in "ct" which is embedded in my main lisp routine as part of my many other routines and i can do crossing on whole drawing if I wanted to, over lines, attributes, etc and when I hit return, I input old value and new value and it changes applicable text. If there is a way to modify the one I posted to be able to change mtext also, that would be awesome. I don't like to use "find" because you have to make sure you select upper right icon to select part of drawing you want which the "ct" routine does that. I hope I didn't make you mad, not my intention BIGAL.

Thank you,
David

CAB:
Quick fix is to change  chgahtext to ct, both places.Then move this line  (setq ss (ssget (list (cons 0 "*text"))))up to just below the line (defun c:chgahtext  ( / ans ss told tnew tobj x)Give that a try.

notredave:
CAB,

Thank you very much for your input but it's still not what I'm looking for it to do. I would like the lisp routine I attached earlier to be modified by working on mtext also. I would like everything else to stay the same because it works now. I would prefer not to have it load "multi getvals.lsp" also. I'm sorry if I'm sounding like a pain in the you know what. Please try routine I have attached to see what I'm talking about. If modification of text, mtext and attributes all in one would be strong!!

Thank you in advance,
David

Navigation

[0] Message Index

[#] Next page

Go to full version