How would this work with MLeaders? I have just added the "Multileader" piece. If selects it, but does not unformat it.
(defun c:unformat ( / *error* enx idx rgx sel str )
(defun *error* ( msg )
(if (and (= 'vla-object (type rgx)) (not (vlax-object-released-p rgx)))
(vlax-release-object rgx)
)
(if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
(princ (strcat "\nError: " msg))
)
(princ)
)
(cond
( (or (vl-catch-all-error-p (setq rgx (vl-catch-all-apply 'vlax-get-or-create-object '("vbscript.regexp"))))
(null rgx)
)
(princ "\nUnable to interface with RegExp object.")
)
( (setq sel (ssget "_:L" '((0 . "MTEXT,MULTILEADER"))))
(repeat (setq idx (sslength sel))
(setq enx (entget (ssname sel (setq idx (1- idx))))
str (assoc 1 enx)
)
(entmod (subst (cons 1 (LM:quickunformat rgx (cdr str))) str enx))
)
)
)
(*error* nil) (princ)
)
;; Quick Unformat - Lee Mac
;; Returns a string with all MText formatting codes removed.
;; rgx - [vla] Regular Expressions (RegExp) Object
;; str - [str] String to process
(defun LM:quickunformat ( rgx str )
(if
(null
(vl-catch-all-error-p
(setq str
(vl-catch-all-apply
'(lambda nil
(vlax-put-property rgx 'global actrue)
(vlax-put-property rgx 'multiline actrue)
(vlax-put-property rgx 'ignorecase acfalse)
(foreach pair
'(
("\032" . "\\\\\\\\")
(" " . "\\\\P|\\n|\\t")
("$1" . "\\\\(\\\\[ACcFfHKkLlOopQTW])|\\\\[ACcFfHKkLlOopQTW][^\\\\;]*;|\\\\[ACcFfKkHLlOopQTW]")
("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);")
("$1$2" . "\\\\(\\\\S)|[\\\\](})|}")
("$1" . "[\\\\]({)|{")
("\\$1$2$3" . "(\\\\[ACcFfHKkLlOoPpQSTW])|({)|(})")
("\\\\" . "\032")
)
(vlax-put-property rgx 'pattern (cdr pair))
(setq str (vlax-invoke rgx 'replace str (car pair)))
)
)
)
)
)
)
str
)
)
(vl-load-com) (princ)