Author Topic: Reset MTEXT fonts  (Read 3260 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Reset MTEXT fonts
« on: June 04, 2010, 12:42:51 PM »
Hi all..

I didn't found any way in AutoCAD to reset Mtext Fonts without selecting and editing each MTEXT.
so I've created this and share with you.

but I'm always curious to see your code.
have a good week end !

Code: [Select]
;| RESET MTEXT FONTS |;
(defun c:RMTF (/ allmtext tc text fs fe ttc ed)
(vl-load-com)
  (setq allmtext (ssget "X" '((0 . "MTEXT"))))
  (repeat (setq n (sslength allmtext))
    (setq tc nil)
    (setq text (cdr
                 (assoc 1
                        (setq item (entget (ssname allmtext (setq n (1- n)))))
                 )
               )
    )
    (while (vl-string-search "\\f" text)
      (setq fs (vl-string-search "\\f" text))
      (setq fe (vl-string-search ";" (substr text (1+ fs))))
      (setq ttc (substr text (1+ fs) (1+ fe)))
      (setq text (vl-string-subst "" ttc text))
      (setq tc t)
    )
    (if tc
      (progn (setq ed (subst (cons 1 text) (assoc 1 item) item))
             (entmod ed)
      )
    )
  )
)
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Reset MTEXT fonts
« Reply #1 on: June 04, 2010, 01:21:43 PM »

Hangman

  • Swamp Rat
  • Posts: 566
Re: Reset MTEXT fonts
« Reply #2 on: June 05, 2010, 07:33:50 PM »
I've recently noticed that when I change an mtext from standard to one of our text styles, it changes the text to the style, but the width, height, & spacing are not updated.  I was getting ready to start looking into this a bit more.
So thank you Andrea, I will look at this more this coming week.
I like that program Lee linked to, but I need some simple code that will update the text automatically, without a dialog box or user input.
Thanks guys.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Reset MTEXT fonts
« Reply #3 on: June 05, 2010, 07:45:00 PM »
MText formatting codes will lead you down a rabbit hole...  :cry:

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Reset MTEXT fonts
« Reply #4 on: June 07, 2010, 10:27:33 AM »
update...

Code: [Select]
(defun c:RMTF (/ allmtext tc text fs fe ttc ed)
  (setq allmtext (ssget "X" '((0 . "MTEXT"))))
  (repeat (setq n (sslength allmtext))
    (setq tc nil)
    (setq text (cdr
                 (assoc 1
                        (setq item (entget (ssname allmtext (setq n (1- n)))))
                 )
               )
    )
    (while (vl-string-search "\\F" (strcat text))
      (setq fs (vl-string-search "\\F" (strcat text)))
      (setq fe (vl-string-search ";" (substr text (1+ fs))))
      (setq ttc (substr text (1+ fs) (1+ fe)))
      (setq text (vl-string-subst "" ttc text))
      (setq tc t)
    )
    (if tc
      (progn (setq ed (subst (cons 1 text) (assoc 1 item) item))
             (entmod ed)
      )
    )
  )
)

thanks... I've wrote this program quickly to change only the FONT and not the color or textsize..beacause some drawing received by client do not provide there fonts and prevent to not resize some title textsize and color for printing with there CTB.

thanks for the Link Lee !  ;-)
Keep smile...