To Find and Replace whole matching Text, try this.......
(defun C:MLTRA ( / Txt_Find Txt_Repl ss) ;; MultiLeader Text Replace All
(setq Txt_Find (getstring t "\nMultileader Text to Replace: "))
(setq Txt_Repl (getstring t "\nMultileader Text to Replace With: "))
(if (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 304 Txt_Find))))
(foreach Ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(vla-put-textstring (vlax-ename->vla-object Ent) Txt_Repl)
)
)
(princ)
)
To Find and Replace a part of matching Text with all occurrences , try this.......
(defun C:MLTRP ( / Txt_Find Txt_Repl ss obj txt_str) ;; MultiLeader Text Replace Part
(setq Txt_Find (getstring t "\nMultileader Text to Replace: "))
(setq Txt_Repl (getstring t "\nMultileader Text to Replace With: "))
(if (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 304 (strcat "*" Txt_Find "*")))))
(foreach Ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq txt_str (vla-get-textstring (setq obj (vlax-ename->vla-object Ent))))
(while (vl-string-search Txt_Find txt_str)
(setq txt_str (vl-string-subst Txt_Repl Txt_Find txt_str))
)
(vla-put-textstring obj txt_str)
)
)
(princ)
)
Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....