Author Topic: StripFontFormat  (Read 1677 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 851
StripFontFormat
« on: February 26, 2020, 11:35:41 AM »
Does anyone have a routine that will strip the font formating in Mtext? 

I've lost mine  :idiot2: and don't have time to re-right  it.  Even a road map would be helpful

Thanks for any info!
James Buzbee
Windows 8

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: StripFontFormat
« Reply #1 on: February 26, 2020, 12:03:38 PM »
I drink beer and I know things....

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: StripFontFormat
« Reply #2 on: February 26, 2020, 02:32:56 PM »
Here's a lightweight program to strip all formatting (you can't pick & choose as you can with StripMText).

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: StripFontFormat
« Reply #3 on: February 27, 2020, 12:18:44 PM »
Thanks Lee
James Buzbee
Windows 8

ahsattarian

  • Newt
  • Posts: 112
Re: StripFontFormat
« Reply #4 on: November 22, 2020, 02:47:30 PM »
check these    :




Code - Auto/Visual Lisp: [Select]
  1. (defun c:mtxstrip1 ()
  2.   (setq ss (ssget '((0 . "mtext,dimension,multileader"))))
  3.   (setq n (sslength ss))
  4.   (setq k -1)
  5.   (repeat n
  6.     (setq k (1+ k))
  7.     (setq s (ssname ss k))
  8.     (setq en (entget s))
  9.     (setq typ (strcase (cdr (assoc 0 en)) t))
  10.     (setq ass 1)
  11.     (cond ((= typ "multileader") (setq ass 304)))
  12.     (setq txt1 (cdr (assoc ass en)))
  13.     (setq txt2 "")
  14.     (setq i 1)
  15.     (setq len (strlen txt1))
  16.     (while (<= i len)
  17.       (setq let (substr txt1 i 1))
  18.       (if (= let "\\")
  19.         (progn
  20.           (setq i (1+ i))
  21.           (setq let (substr txt1 i 1))
  22.           (if (or (= let "{") (= let "}") (= let "\\") (= let "P"))
  23.             (setq txt2 (strcat txt2 "\\" let))
  24.             (while (and (/= let ";") (<= i len)) (setq i (1+ i)) (setq let (substr txt1 i 1)))
  25.           )
  26.         )
  27.         (cond ((and (/= let "{") (/= let "}")) (setq txt2 (strcat txt2 let))))
  28.       )
  29.       (setq i (1+ i))
  30.     )
  31.     (cond ((/= txt1 txt2) (setq en (subst (cons ass txt2) (assoc ass en) en)) (entmod en)))
  32.   )
  33. )




Code - Auto/Visual Lisp: [Select]
  1. (defun c:mtxstrip2 ()
  2.   (setq ss (ssget '((0 . "MTEXT"))))
  3.   (setq n (sslength ss))
  4.   (setq k -1)
  5.   (repeat n
  6.     (setq k (1+ k))
  7.     (setq s (ssname ss k))
  8.     (setq obj (vlax-ename->vla-object s))
  9.     (setq text (vla-get-textstring obj))
  10.     (setq len (strlen text))
  11.     (setq i 0)
  12.     (setq libad '(123 125 92 59))
  13.     (setq text2 "")
  14.     (setq bad 0)
  15.     (repeat len
  16.       (setq i (1+ i))
  17.       (setq let (substr text i 1))
  18.       (setq asci (ascii let))
  19.       (cond ((= asci 92) (setq bad 1)))
  20.       (cond ((and (= asci 59) (= bad 1)) (setq bad 0)))
  21.       (cond ((and (not (member asci libad)) (= bad 0)) (setq text2 (strcat text2 let))))
  22.       (if (and (= let "\\") (setq let2 (substr text (1+ i) 1)) (= let2 "P"))
  23.         (progn (setq text2 (strcat text2 let let2)) (setq bad 0) (setq i (1+ i)))
  24.       )
  25.     )
  26.     (vla-put-textstring obj text2)
  27.   )
  28. )




EDIT (John): Added code tags.
« Last Edit: December 10, 2020, 03:24:14 PM by John Kaul (Se7en) »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: StripFontFormat
« Reply #5 on: November 22, 2020, 03:18:58 PM »
@ahsattarian:
Can you please use code tags? Thanks.
You can either use the Code dropdown list and select AutoLisp, or use the '#' button.