Author Topic: StripFontFormat  (Read 539 times)

0 Members and 1 Guest are viewing this topic.

jbuzbee

  • Swamp Rat
  • Posts: 850
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: 12411
  • 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: 850
Re: StripFontFormat
« Reply #3 on: February 27, 2020, 12:18:44 PM »
Thanks Lee
James Buzbee
Windows 8

ahsattarian

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




(defun c:mtxstrip1 ()
  (setq ss (ssget '((0 . "mtext,dimension,multileader"))))
  (setq n (sslength ss))
  (setq k -1)
  (repeat n
    (setq k (1+ k))
    (setq s (ssname ss k))
    (setq en (entget s))
    (setq typ (strcase (cdr (assoc 0 en)) t))
    (setq ass 1)
    (cond ((= typ "multileader") (setq ass 304)))
    (setq txt1 (cdr (assoc ass en)))
    (setq txt2 "")
    (setq i 1)
    (setq len (strlen txt1))
    (while (<= i len)
      (setq let (substr txt1 i 1))
      (if (= let "\\")
   (progn
     (setq i (1+ i))
     (setq let (substr txt1 i 1))
     (if (or (= let "{") (= let "}") (= let "\\") (= let "P"))
       (setq txt2 (strcat txt2 "\\" let))
       (while (and (/= let ";") (<= i len)) (setq i (1+ i)) (setq let (substr txt1 i 1)))
     )
   )
   (cond ((and (/= let "{") (/= let "}")) (setq txt2 (strcat txt2 let))))
      )
      (setq i (1+ i))
    )
    (cond ((/= txt1 txt2) (setq en (subst (cons ass txt2) (assoc ass en) en)) (entmod en)))
  )
)




(defun c:mtxstrip2 ()
  (setq ss (ssget '((0 . "MTEXT"))))
  (setq n (sslength ss))
  (setq k -1)
  (repeat n
    (setq k (1+ k))
    (setq s (ssname ss k))
    (setq obj (vlax-ename->vla-object s))
    (setq text (vla-get-textstring obj))
    (setq len (strlen text))
    (setq i 0)
    (setq libad '(123 125 92 59))
    (setq text2 "")
    (setq bad 0)
    (repeat len
      (setq i (1+ i))
      (setq let (substr text i 1))
      (setq asci (ascii let))
      (cond ((= asci 92) (setq bad 1)))
      (cond ((and (= asci 59) (= bad 1)) (setq bad 0)))
      (cond ((and (not (member asci libad)) (= bad 0)) (setq text2 (strcat text2 let))))
      (if (and (= let "\\") (setq let2 (substr text (1+ i) 1)) (= let2 "P"))
   (progn (setq text2 (strcat text2 let let2)) (setq bad 0) (setq i (1+ i)))
      )
    )
    (vla-put-textstring obj text2)
  )
)





roy_043

  • Water Moccasin
  • Posts: 1835
  • 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.