Results 1 to 6 of 6

Thread: Help with application to remove mtext overrides.

  1. #1
    Member
    Join Date
    2004-02
    Posts
    13
    0 Did you find this post helpful? Yes

    Default 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.

  2. #2
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    211
    0 Did you find this post helpful? Yes

    Default 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...
    Use AUTOCAD / ADT / AA 2006 / 2008 / 2010
    All i say is only my opinion
    I'm watching you! Your

  3. #3
    Administrator Mike.Perry's Avatar
    Join Date
    2001-03
    Posts
    13,499
    0 Did you find this post helpful? Yes

    Default Re: Help with application to remove mtext overrides.

    Hi

    Additionally you may wish to review the following posts...

    RE: Dimension text...

    RE: How to format MT globally?

    RE: MText Font / Style formatting issues

    Have a good one, Mike

  4. #4
    Member
    Join Date
    2004-02
    Posts
    13
    0 Did you find this post helpful? Yes

    Default 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.
    Last edited by mikeevans; 2007-01-15 at 11:03 AM. Reason: Removed comments as they were incorrect.

  5. #5
    I could stop if I wanted to kpblc2000's Avatar
    Join Date
    2006-09
    Posts
    211
    0 Did you find this post helpful? Yes

    Default Re: Help with application to remove mtext overrides.

    I'm terribly sorry. Try this:
    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 
                   (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))
                  ) ;_ end of setq
            (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
                       "Working throught [All files/Selection]? <All> : "
                       ) ;_ 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
    Use AUTOCAD / ADT / AA 2006 / 2008 / 2010
    All i say is only my opinion
    I'm watching you! Your

  6. #6
    AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    1,390
    0 Did you find this post helpful? Yes

    Default 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.
    Tom Beauford P.S.M. - Civil 2013 on Windows 7 Pro
    Design Analysis - Leon County Public Works/Engineering
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516

Similar Threads

  1. 2011: Globally remove mtext formatting
    By anetace in forum AutoCAD General
    Replies: 3
    Last Post: 2012-01-03, 10:34 PM
  2. Remove formatting from MText objects
    By kwong in forum AutoCAD General
    Replies: 1
    Last Post: 2007-02-12, 02:53 AM
  3. Eliminate Mtext Overrides?
    By stilesj in forum AutoCAD General
    Replies: 2
    Last Post: 2007-01-04, 02:25 PM
  4. Remove Font formatting in MText
    By tedg in forum AutoCAD General
    Replies: 5
    Last Post: 2006-03-23, 03:26 AM
  5. Edit MText when using an external application
    By ruthellenwilliams in forum AutoCAD General
    Replies: 1
    Last Post: 2006-03-07, 05:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •