TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jbuzbee on February 26, 2020, 11:35:41 AM

Title: StripFontFormat
Post by: jbuzbee 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!
Title: Re: StripFontFormat
Post by: Slim© on February 26, 2020, 12:03:38 PM
http://www.theswamp.org/index.php?topic=31584.0 (http://www.theswamp.org/index.php?topic=31584.0)
Title: Re: StripFontFormat
Post by: Lee Mac on February 26, 2020, 02:32:56 PM
Here's (https://www.theswamp.org/index.php?topic=52929.msg577561#msg577561) a lightweight program to strip all formatting (you can't pick & choose as you can with StripMText).
Title: Re: StripFontFormat
Post by: jbuzbee on February 27, 2020, 12:18:44 PM
Thanks Lee
Title: Re: StripFontFormat
Post by: ahsattarian 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.
Title: Re: StripFontFormat
Post by: roy_043 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.