Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remove text underline

29 REPLIES 29
Reply
Message 1 of 30
Anonymous
11117 Views, 29 Replies

Remove text underline

Anyone have a routine to remove underlining from multiple dtext & mtext
objects?
29 REPLIES 29
Message 21 of 30
Anonymous
in reply to: Anonymous

Thank you both.

Ken Krupa

sdoman wrote:
> Hi people,
>
> I noticed some confusion about StripMtext and where to get the latest version.
>
> The most current version of StripMtext is 3.09. This version exposes a function called Unformat written by John Uhden which does the actual work of removing formatting codes from Mtext objects. Thus by loading StripMtext you may then call Unformat from your own AutoLISP code or by script.
>
> It can be downloaded here: http://cadabyss.wordpress.com/
>
> Hope that helps. Thanks for the favorable comments and I wish I could hang out here all day and talk code with you.
>
> Regards,
> Steve Doman
Message 22 of 30
Anonymous
in reply to: Anonymous

Thanks for all the effort and suggesttions but I am not clear as to how to
proceed. As mentionedearlier I have Ver 3.05 and now the latest V3.09 (btw
Steve - the princ line at the end reads v3.08). I do not have ver 2.
Can you point me to the lines that need to be adjusted?
Message 23 of 30
Anonymous
in reply to: Anonymous

If you only need to remove underlining and not other formatting, then you can
use the solution I posted that use the stripmtext21.lsp file that I attached -
it's good to go as is, and answers what you were looking to do.

On the other hand, if you want to remove other or all formatting from mtext,
now that you know it can, let us know what you want it to do (remove all, or
specify specific others).

Ken Krupa

KDispoto wrote:
> Thanks for all the effort and suggestions but I am not clear as to how to
> proceed. As mentioned earlier I have Ver 3.05 and now the latest V3.09 (btw
> Steve - the princ line at the end reads v3.08). I do not have ver 2.
> Can you point me to the lines that need to be adjusted?
Message 24 of 30
BIG_DAHEEY
in reply to: Anonymous

JUST ENTER "%%U" IN THE FRONT OF YOUR FIRST LETTER. 

Message 25 of 30
Kent1Cooper
in reply to: BIG_DAHEEY


@EWOK4LIFE wrote:

JUST ENTER "%%U" IN THE FRONT OF YOUR FIRST LETTER. 


[Ten-year-old thread, but nevertheless, for the sake of others Searching for this kind of question....]

 

That's not a solution:

 

1)  It won't work for Mtext [see the original request in Post 1], at least in newer versions [I think %%U was the underlining toggle also inside Mtext in old-enough versions, but I'm not sure how far back].

 

2)  It will only remove  underlining [see the Subject line] if  the Text is underlined from the beginning and for its entire length.  If it's partially  underlined, the places where the switchover occurs will change to switch in the opposite direction, but there will still be underlining:

underline.PNG

 

3)  If there is currently no  underlining, it will add  underlining to the whole thing, the opposite of the original request.

Kent Cooper, AIA
Message 26 of 30
BIG_DAHEEY
in reply to: Kent1Cooper

I was under the impression that he wanted the underline removed...


Message 27 of 30
john.uhden
in reply to: Anonymous

If it might help, here is the original @Unformat function from 2003:

(@Unformat ename "L") or (@Unformat Object "L") will hopefully work for you.

The Formats argument is NOT case-sensitive.

 

  (defun @UnFormat (Mtext Formats / All Format1 Format2 Text Str)
    ;;--------------------------------------------------
    ;; Primary function to perform the format stripping:
    ;; (04-20-03) John F. Uhden, Cadlantic
    ;; Arguments:
    ;;   Mtext   - the Mtext VLA-Object or Ename
    ;;   Formats - a string containing some or all of the following characters:
    ;;     A - Alignment
    ;;     C - Color
    ;;     F - Font
    ;;     H - Height
    ;;     L - Underscore
    ;;     O - Overscore
    ;;     P - Linefeed (Paragraph)
    ;;     Q - Obliquing
    ;;     S - Spacing (Stacking)
    ;;     T - Tracking
    ;;     W - Width
    ;;     ~ - Non-breaking Space
    ;;   Optional Formats -
    ;;     * - All formats
    ;; Returns:
    ;;   nil  - if not a valid Mtext object
    ;;   Text - the Mtext textstring with none, some, or all
    ;;          of the formatting removed, depending on what
    ;;          formats were present and what formats were
    ;;          specified for removal.
    ;;
    (cond
      ((= (type Mtext) 'VLA-Object))
      ((= (type Mtext) 'ENAME)
        (setq Mtext (vlax-ename->vla-object Mtext))
      )
      (1 (setq Mtext nil))
    )
    (and
      Mtext
      (= (vlax-get Mtext 'ObjectName) "AcDbMText")
      (= (type Formats) 'STR)
      (setq Formats (strcase Formats))
      (setq Mtext (vlax-get Mtext 'TextString))
      (setq Text "")
      (setq All T)
      (if (= Formats "*")
        (setq Formats "S"
              Format1 "\\[LOP`~]"
              Format2 "\\[ACFHQTW]"
        )
        (progn
          (setq Format1 "" Format2 "")
          (foreach item '("L" "O" "P" "~")
            (if (vl-string-search item Formats)
              (setq Format1 (strcat Format1 "`" item))
              (setq All nil)
            )
          )
          (if (= Format1 "")
            (setq Format1 nil)
            (setq Format1 (strcat "\\[" Format1 "]"))
          )
          (foreach item '("A" "C" "F" "H" "Q" "T" "W")
            (if (vl-string-search item Formats)
              (setq Format2 (strcat Format2 item))
              (setq All nil)
            )
          )
          (if (= Format2 "")
            (setq Format2 nil)
            (setq Format2 (strcat "\\[" Format2 "]"))
          )
          T
        )
      )
      (while (/= Mtext "")
        (cond
          ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}]")
            (setq Mtext (substr Mtext 3)
                  Text   (strcat Text Str)
            )
          )
          ((and All (wcmatch (substr Mtext 1 1) "[{}]"))
            (setq Mtext (substr Mtext 2))
          )
          ((and Format1 (wcmatch (strcase (substr Mtext 1 2)) Format1))
            (setq Mtext (substr Mtext 3))
          )
          ((and Format2 (wcmatch (strcase (substr Mtext 1 2)) Format2))
            (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))
          )
          ((and (vl-string-search "S" Formats)(wcmatch (strcase (substr Mtext 1 2)) "\\S"))
            (setq Str   (substr Mtext 3 (- (vl-string-search ";" Mtext) 2))
                  Text  (strcat Text (vl-string-translate "#^\\" "   " Str))
                  Mtext (substr Mtext (+ 4 (strlen Str)))
            )
          )
          (1
            (setq Text (strcat Text (substr Mtext 1 1))
                  Mtext (substr Mtext 2)
            )
          )
        )
      )
    )
    Text
  )

John F. Uhden

Message 28 of 30
Anonymous
in reply to: Anonymous

Wow great man!

Thank you very much,, save lot of my time..

 

B

Message 29 of 30
BIG_DAHEEY
in reply to: Anonymous

No problem! Thanks for replying


Message 30 of 30
zph
Collaborator
in reply to: BIG_DAHEEY

I wrote one a while back that works for TEXT and MTEXT entities.

 

It toggles the removal and addition of the underline.

 

Let me know if it helps 🙂

~Z

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost