I have the following lisp which is modified from something Kent Cooper posted somewhere. It will change the text style of all text or mtext even if they are in a block or attribute definition. It does work well for this. The only thing I modified was to add a prompt to define what the replacement style would be. I was trying to use this to purge all disparate styles within the drawing.
The only thing I cannot figure how to do is to also replace all the text styles within dimension styles. I've went round and round with Copilot and always there is an error when trying to reference the TextStyle property of a dimstyle. Here's the working lisp for changing all text styles:
(defun C:CTS ()
;; = Text (& Mtext) [to] specified Style, including in Blocks,
;; and Attributes, both in Blocks & unassociated Att. Def's
;; Created by KENT COOPER, AIA and edited by InSub Beckley.
;; v2.0 makes the newStyle user definable instead of hardcoded.
(vl-load-com) ; Ensure Visual LISP functions are loaded
(setq newStyle (getstring "\nEnter the new text style name: "))
(setq tss (ssget "_X" '((0 . "*TEXT,ATTDEF"))))
(if tss
(repeat (setq n (sslength tss))
(setq edata (entget (ssname tss (setq n (1- n)))))
(entmod (subst (cons 7 newStyle) (assoc 7 edata) edata))
); repeat
); if
(setq blkname nil blklist nil)
(while (setq blkname (cdadr (tblnext "block" (not blkname))))
(if
(not
(or
(wcmatch blkname "`*D*,*|*") ; Dimension or Xref-dependent
(assoc 1 (tblsearch "block" blkname)) ; an Xref
(member blkname blklist) ; already in the list
); or
); not
(setq blklist (cons blkname blklist))
); if
); while
(foreach blkname blklist
(setq ent (tblobjname "block" blkname))
(while (setq ent (entnext ent))
(if (wcmatch (cdr (assoc 0 (setq edata (entget ent)))) "*TEXT,ATTDEF")
(entmod (subst (cons 7 newStyle) (assoc 7 edata) edata))
); if
); while
); foreach
(command
"_.regen"
"_.attsync" "_name" "*"
); command
(princ)
); defun