Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

UNDERLINE MULTIPLE MTEXT ENTITIES

cleftwich
Enthusiast

UNDERLINE MULTIPLE MTEXT ENTITIES

cleftwich
Enthusiast
Enthusiast

Does anyone know how to underline multiple mtext entities at one time through a lisp or other means. Currently I use an archaic and time consuming way of completing this task, any help would be appreciated greatly,

 

Thanks,

Charles

0 Me gusta
Responder
Soluciones aceptadas (2)
7.778 Vistas
23 Respuestas
Respuestas (23)

sam_underdown
Observer
Observer

sam_underdown_0-1689775468049.png

Please see the above screen snip

 

the underline goes under all characters, so i am not sure what is causing the issue, lisp routines are new to me so apologies if i am asking silly questions

 

the command still fails and returns the following 

Command: (cdr(assoc1(entget(car(entsel)))))

Select object: ; error: no function definition: ASSOC1

 

i have attached the cad file i am having trouble with so you can take a look, perhaps i am missing something obvious? 

0 Me gusta

Kent1Cooper
Consultant
Consultant

Your pasting-in of the code snippet lost all spaces.  Some of them don't matter, but the one between assoc and 1 is necessary.

 

But anyway, those Mtexts somehow do the underlining in a different way than currently, without the { } "wrapper" around formatted parts.  A sample instance returns:

"\\L+39.600"

So those don't meet the filter criteria for the content, which is why UUMT's object selection didn't "see" them.  But sure enough, when edited to remove the +, it automatically gets "updated" to the current practice:

"{\\L39.600}"

Even simply double-clicking on one to get into Mtext-editing, and then clicking away to get out of it, without changing anything, causes the same update of the formatting code, so it's not about the + per se.

Maybe that no-{} way comes from an older version, or something brought in from other software, or....

 

But that "option" in the way the underlining is coded can be accounted for [minimally tested]:

 

(defun C:UUMT (/ ss n edata txt); = Un-Underline MText(s)
  ;; to remove underlining from Mtext whose ENTIRE content is underlined
  (if (setq ss (ssget "_:L" '((0 . "MTEXT") (1 . "{\\L*,\\L*"))))
    (repeat (setq n (sslength ss)); then
      (setq
        edata (entget (ssname ss (setq n (1- n))))
        txt (cdr (assoc 1 edata))
      ); setq
      (entmod
        (subst
          (cons 1
            (if (= (substr txt 1 1) "{")
              (substr txt 4 (- (strlen txt) 4))
              (substr txt 3)
            ); if
          ); cons
          (assoc 1 edata)
          edata
        ); subst
      ); entmod
    ); repeat
  ); if
  (princ)
)

 

Kent Cooper, AIA

sam_underdown
Observer
Observer

@Kent1Cooper it works perfectly now, thank you so much for your help, it's appreciated! 

0 Me gusta

Kent1Cooper
Consultant
Consultant

How about this?  A universal one, all in one command for not only Text and Mtext but also MultiLeaders and text-overridden Dimensions [again -- entire content underlined for all but plain Text].  Lightly tested.

;| UnUnderlineText.lsp [command name: UUT]
To remove all underlining from plain Text objects, and from Mtext and MultiLeader
  and text-overridden Dimension objects whose ENTIRE content is underlined.
Not for Mtext/MultiLeaders with long-enough text to go into multiple text-content
  entries [DXF codes 3 and 1] in entity data.
Kent Cooper, 19 July 2023
|;

(defun C:UUT (/ ss n edata etype txtdxf txt); = Un-Underline Text(s)
  (if
    (setq ss
      (ssget "_:L"
        '( ; filter list
          (-4 . "<OR")
            (-4 . "<AND") (0 . "TEXT") (1 . "*%%U*") (-4 . "AND>")
            (-4 . "<AND") (0 . "MTEXT,DIMENSION") (1 . "{\\L*,\\L*") (-4 . "AND>")
            (-4 . "<AND") (0 . "MULTILEADER") (304 . "{\\L*,\\L*") (-4 . "AND>")
          (-4 . "OR>")
        ); filter list
      ); ssget
    ); setq
    (repeat (setq n (sslength ss)); then
      (setq
        edata (entget (ssname ss (setq n (1- n))))
        etype (substr (cdr (assoc 0 edata)) 1 2); "TE" / "MT" / "MU" / "DI"
        txtdxf (if (= etype "MU") 304 1)
        txt (cdr (assoc txtdxf edata))
      ); setq
      (if (= etype "TE")
        (while (wcmatch txt "*%%U*") ; then [Text]
          (setq txt (vl-string-subst "" "%%U" txt))
        ); while
        (setq txt ; else [Mtext/MultiLeader/Dimension]
          (if (= (substr txt 1 1) "{")
            (substr txt 4 (- (strlen txt) 4))
            (substr txt 3)
          ); if
        ); setq
      ); if
      (entmod (subst (cons txtdxf txt) (assoc txtdxf edata) edata))
    ); repeat
  ); if
  (princ)
); defun
Kent Cooper, AIA
0 Me gusta