Jump to content

put line over text or mtext


leonucadomi

Recommended Posts

Hi, I would like to know if you know of any routine that can be used to select a group of texts or mtext and put a line above them.

image.thumb.png.bee5a11af649bc0bd43f9dc9a8011c61.png

 

any comment is welcomed

Link to comment
Share on other sites

Try this:

(defun c:foo (/ o s)
  (if (setq s (ssget ":L" '((0 . "*TEXT"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (if (= "TEXT" (cdr (assoc 0 (entget e))))
	(vla-put-textstring o (strcat "%%O" (vl-string-left-trim "%%O" (vla-get-textstring o))))
	(vla-put-textstring o (strcat "\\O" (vl-string-left-trim "\\O" (vla-get-textstring o))))
      )
    )
  )
  (princ)
)

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...

Hi,

Very practice routine!

Do you know how to put the line:

      -below the text/mtext

      -below and above the text/mtext

And possibilities to delete line after.

Thanks for your answer.

Link to comment
Share on other sites

On 9/6/2024 at 1:47 AM, thekiki said:

Hi,

Very practice routine!

Do you know how to put the line:

      -below the text/mtext

      -below and above the text/mtext

And possibilities to delete line after.

Thanks for your answer.

Here's a simple mod to put an underline and an overline:
 

(defun c:foo (/ o s)
  (if (setq s (ssget ":L" '((0 . "*TEXT"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (if (= "TEXT" (cdr (assoc 0 (entget e))))
	(vla-put-textstring o (strcat "%%U%%O" (vl-string-left-trim "%%U%%O" (vla-get-textstring o))))
	(vla-put-textstring o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textstring o))))
      )
    )
  )
  (princ)
)

 

Edited by ronjonp
Link to comment
Share on other sites

Pkenewell, thanks for your advice. It works only for Mtext.

 

The Ronjonp's lisp works perfect for Mtext/Text. But if i want to delete the lines, how can i do for that.

And can you modify the lisp to put the line only below the mtext/text.

Thanks again!

Link to comment
Share on other sites

15 hours ago, ronjonp said:

Here's a simple mod to put an underline and an overline:
 

(defun c:foo (/ o s)
  (if (setq s (ssget ":L" '((0 . "*TEXT"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq o (vlax-ename->vla-object e))
      (if (= "TEXT" (cdr (assoc 0 (entget e))))
	(vla-put-textstring o (strcat "%%U%%O" (vl-string-left-trim "%%U%%O" (vla-get-textstring o))))
	(vla-put-textstring o (strcat "\\L\\O" (vl-string-left-trim "\\L\\O" (vla-get-textstring o))))
      )
    )
  )
  (princ)
)

 

 

Minor nitpick 😉: note that the string-*-trim functions operate with characters rather than strings, and so strictly speaking only "%UO" is required as the string argument, however, as a side effect, note that this will also strip out possible formatting following the overline/underline specifiers, e.g. "%%U%%O%%DABC" would become "DABC". An alternative solution might be to use vl-string-search + substr (as I'm sure you already know 🙂)

Edited by Lee Mac
Link to comment
Share on other sites

5 hours ago, thekiki said:

Pkenewell, thanks for your advice. It works only for Mtext.

 

The Ronjonp's lisp works perfect for Mtext/Text. But if i want to delete the lines, how can i do for that.

And can you modify the lisp to put the line only below the mtext/text.

Thanks again!

@thekiki

This is just as easy with TEXT. Just type in the text, then hit the home key to go to the beginning and type "%%U%%O" and voila - done!

To REMOVE the formatting, just edit the test, highlight it, then hit CTRL+X and CTRL+V - and voila - formatting removed!

Edited by pkenewell
Link to comment
Share on other sites

Your method is working. But if i have many text/Mtext, it will take longtime.

Ronjonp's lisp is perfect. But i need to modify it to delete line.

Many thanks!

Link to comment
Share on other sites

9 hours ago, Lee Mac said:

 

Minor nitpick 😉: note that the string-*-trim functions operate with characters rather than strings, and so strictly speaking only "%UO" is required as the string argument, however, as a side effect, note that this will also strip out possible formatting following the overline/underline specifiers, e.g. "%%U%%O%%DABC" would become "DABC". An alternative solution might be to use vl-string-search + substr (as I'm sure you already know 🙂)

Ah yes .. I've done this in the past with regrets :) .. hope you're doing well Lee! :beer:

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...