Some Like This
(defun c:TEcolor136_230
(/ error oldcmdecho sel e typo obj res currentColor n ch? tx)
(vl-load-com)
(defun error (msg)
(if oldcmdecho
(setvar "CMDECHO" oldcmdecho)
)
(if (and msg (not (wcmatch (strcase msg) "BREAK,CANCEL,EXIT")))
(princ (strcat "Error: " msg))
)
(princ)
)
(setq oldcmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setvar "NOMUTT" 1)
;;; (while (setq sel (entsel "\nSelect TEXT/MTEXT to edit (Enter — exit): "))
(princ "\nSelect TEXTs/MTEXTs to edit (Enter — exit): ")
(setq sel (ssget '((0 . "*TEXT")))
e (ssname sel 0)
;;; typo (strcase (cdr (assoc 0 (entget e))))
)
(if sel
(progn
(setq obj (vlax-ename->vla-object e)
tx (cdr (assoc 1 (entget e)));(vla-getTextString obj)
)
;; get the current color
(setq currentColor (vl-catch-all-apply 'vlax-get-property (list obj 'Color)))
;; Error handling on receipt
(if (vl-catch-all-error-p currentColor)
(setq currentColor 0)
)
(princ "\rEdit text and left click on empty screen for continue")
;; Opening the text editor (getstring)
(setq n -1
res (vl-catch-all-apply 'vl-cmdf (list "_.textedit" e ""))
ch? (/= tx (setq tx (cdr (assoc 1 (entget e)))))
)
(if (vl-catch-all-error-p res)
(princ "\nEditing canceled.")
(while (setq e (ssname sel (setq n (1+ n))))
(setq obj (vlax-ename->vla-object e))
(if (and ch? (> n 0))
(entmod (subst (cons 1 tx) (assoc 1 (entget e)) (entget e)))
)
;; After editing, we change the color
(if (= currentColor 136)
;; If it's 136, change it to 230.
(if (vl-catch-all-error-p
(vl-catch-all-apply
'vlax-put-property
(list obj 'Color 230)
)
)
(princ "\nCouldn't change color to 230.")
(princ "\nThe color has been changed to 230.")
)
)
(if (/= currentColor 136)
;; If it's not 136, change it to 136.
(if (vl-catch-all-error-p
(vl-catch-all-apply
'vlax-put-property
(list obj 'Color 136)
)
)
(princ "\nCouldn't change the color to 136.")
(princ "\nThe color has been changed to 136.")
)
)
)
)
(if obj (princ "\nEditing completed."))
)
(princ "\nIt's not an object TEXT/MTEXT.")
)
(setvar "CMDECHO" oldcmdecho)
(setvar "NOMUTT" 0)
(princ)
)