Jump to content

Recommended Posts

Posted

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

Posted

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
  • 4 weeks later...
Posted

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.

Posted

Have a look at BoxTextV1-2.lsp by Lee-mac it is almost what you want, a little edit of the code would remove the 2 ends.

 

BoxTextV1-2.lsp

Posted

Can you show me where remove the 2 ends.

Thanks.

Posted

@thekiki You don't need LISP to do this, Just use the Overline and Underline tools in the MTEXT Editor Tab:

image.png.32f5d6e4aa22bacd37ee5e046ac97746.png image.png.8c952f5da292935d50ba06f02be1bd51.png

  • Like 1
Posted (edited)
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
Posted

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!

Posted (edited)
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
Posted (edited)
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
Posted

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!

Posted
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

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...