Help with application to remove mtext overrides.
I can't find an application to remove the mtext overrides in one hit, I Receive a lot of drawings which have not been drawn bylayer and bystyle and I have to clean them up. For most entities it's not such a demanding task but when I get mtext objects that have been overridden to another font or colour I have to edit each entity individually or explode each one to Dtext.
Exploding is not such an issue but I recently received a file which had text that the first couple of characters were by style the next three were overridden and the final string was by style, when you explode these they change to separate entities based on the font overrides.
Please does anyone know of a way to remove the pesky overrides in one hit or a file that can be used to do this, I remember that R14 allowed the override strings (/l/a/...) to be removed from the editor but the all other versions since do not allow this.
RE: Help with application to remove mtext overrides.
Original code: http://www.autocad.ru/cgi-bin/f1/board.cgi?t=20905TQ
Code:
;|=============================================================================
* Erasing mtext formatting (excepting color)
* Call parameters:
* string-to-normalize — string to reformat
* Call samples:
(_kpblc-clear-mtext (cdr (assoc 1 (entget(car(entsel))))))
=============================================================================|;
(defun _kpblc-clear-mtext (string-to-normalize /
sub_string sub_pos left_string
right_string
)
(if (or
(setq sub_pos (vl-string-search "{f" string-to-normalize))
(setq sub_pos (vl-string-search "{\\" string-to-normalize))
(setq sub_pos (vl-string-search "\\f" string-to-normalize))
(setq sub_pos (vl-string-search "{\\f" string-to-normalize))
) ;_ end of or
(progn
(setq left_string ;âñå, ÷òî äî "{"
(vl-string-trim
"{"
(substr
string-to-normalize
1
(vl-string-position
(ascii "\\")
string-to-normalize
sub_pos
) ;_ end of vl-string-position
) ;_ end of substr
) ;_ end of vl-string-trim
) ;_ end of setq
(if (vl-string-position
(ascii ";")
string-to-normalize
sub_pos
) ;_ end of vl-string-position
(setq right_string ;âñå, ÷òî ìåæäó {f è ;
(substr
string-to-normalize
(+ (vl-string-position
(ascii ";")
string-to-normalize
sub_pos
) ;_ end of vl-string-position
2
) ;_ end of +
) ;_ end of substr
) ;_ end of setq
(setq right_string "")
) ;_ end of if
(_kpblc-clear-mtext (strcat left_string right_string))
) ;_ end of progn
(vl-list->string
(vl-remove
(ascii "}")
(vl-string->list string-to-normalize)
) ;_ end of vl-remove
) ;_ end of vl-list->string
) ;_ end of if
) ;_ end of defun
;; main function
(defun c:unf-mtext (/ selset item _error_ _answer_ layer_set_list layer_status_list)
(defun kpblc-error (message)
(while (/= (getvar "cmdactive") 0)
(command nil)
) ;_while
(vla-endundomark *kpblc-activedoc*)
(setq *error* _error_)
(princ msg)
(princ)
) ;_ end of defun
(defun _kpblc-make-layer-free (layer-name / layer_item)
(setq layer_status_list nil
layer_item (vlax-ename->vla-object
(tblobjname "layer" layer-name)
) ;_ end of vlax-ename->vla-object
layer_status_list (list
(cons
"LayerOn"
(vlax-get-property layer_item "LayerOn")
) ;_ end of cons
(cons
"Lock"
(vlax-get-property layer_item "Lock")
) ;_ end of cons
(cons
"Freeze"
(vlax-get-property layer_item "Freeze")
) ;_ end of cons
) ;_ end of list
) ;_ end of setq
(vlax-put-property layer_item "LayerOn" :vlax-true)
(vlax-put-property layer_item "Lock" :vlax-false)
(if (/=
(vlax-get-property
(vlax-get-property *kpblc-activedoc* "ActiveLayer")
"Name"
) ;_ end of vlax-get-property
layer-name
) ;_ end of /=
(vlax-put-property layer_item "freeze" :vlax-false)
) ;_ end of if
) ;_ end of defun
(defun _kpblc-restore-layer (layer-name / layer_item)
(if layer_status_list
(progn
(setq layer_item (vlax-ename->vla-object (tblobjname "layer" layer-name)))
(foreach loc_item '("LayerOn" "Lock" "Freeze")
(if (and
(/=
(vlax-get-property
(vlax-get-property *kpblc-activedoc* "ActiveLayer")
"Name"
) ;_ end of vlax-get-property
layer-name
) ;_ end of /=
(/= loc_item "Freeze")
) ;_ end of and
(vlax-put-property
layer_item
loc_item
(cdr
(assoc loc_item layer_status_list)
) ;_ end of cdr
) ;_ end of vlax-put-property
) ;_ end of if
) ;_ end of foreach
) ;_ end of progn
) ;_ end of if
(setq layer_status_list nil)
) ;_ end of defun
(vl-load-com)
(initget "All Selection")
(setq _error_ *error*
*error* kpblc-error
_answer_ (getkword
"Îáðàáàòûâàòü îáúåì [âÅñü ôàéë/Âûáîð] ? <Âåñü ôàéë> : "
) ;_ end of getkword
) ;_ end of setq
(if (not *kpblc-activedoc*)
(setq *kpblc-activedoc* (vla-get-activedocument (vlax-get-acad-object)))
) ;_ end of if
(vla-startundomark *kpblc-activedoc*)
(if (= _answer_ "Selection")
(setq selset (ssget '((0 . "MTEXT"))))
(setq selset (ssget "_X" '((0 . "MTEXT"))))
) ;_ end of if
(while (and
selset
(> (sslength selset) 0)
) ;_ end of and
(setq item (ssname selset 0))
(ssdel item selset)
(_kpblc-make-layer-free (cdr (assoc 8 (entget item))))
(vlax-put-property
(vlax-ename->vla-object item)
"TextString"
(_kpblc-clear-mtext
(vlax-get-property (vlax-ename->vla-object item) "TextString")
) ;_ end of _kpblc-clear-mtext
) ;_ end of vlax-put-property
(_kpblc-restore-layer (cdr (assoc 8 (entget item))))
) ;_ end of while
(vla-endundomark *kpblc-activedoc*)
(setq *error* _error_)
) ;_ end of defun
(princ "\ntype unf-mtext for clear mtext format") ;_ end of princ
I think it will helps you...
RE: Help with application to remove mtext overrides.
RE: Help with application to remove mtext overrides.
Thanks for that chaps but the first lisp routine is in Russian and I can't tell what it is asking me to pick in AutoCAD so it fails, Bablefish seemingly won't translate all the Russian text.
At first the Stripmtext function seemed not to work but once I added the Path to the files into the AutoCAD Paths it worked fine. Thanks all for the help, this should save me hours of hassle with external files.
Re: Help with application to remove mtext overrides.
Try StripMtext v5.0
http://cadabyss.wordpress.com/
Dialog box routine that lets you select what types of formating you want striped from the selected Mtext. I've been using it for years.