leonucadomi Posted August 8 Share Posted August 8 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. any comment is welcomed Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 8 Share Posted August 8 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) ) 2 1 Quote Link to comment Share on other sites More sharing options...
thekiki Posted September 6 Share Posted September 6 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 6 Share Posted September 6 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 Quote Link to comment Share on other sites More sharing options...
thekiki Posted September 9 Share Posted September 9 Can you show me where remove the 2 ends. Thanks. Quote Link to comment Share on other sites More sharing options...
pkenewell Posted September 9 Share Posted September 9 @thekiki You don't need LISP to do this, Just use the Overline and Underline tools in the MTEXT Editor Tab: 1 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted September 9 Share Posted September 9 (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 September 9 by ronjonp Quote Link to comment Share on other sites More sharing options...
thekiki Posted September 10 Share Posted September 10 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! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 10 Share Posted September 10 (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 September 10 by Lee Mac Quote Link to comment Share on other sites More sharing options...
pkenewell Posted September 10 Share Posted September 10 (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 September 10 by pkenewell Quote Link to comment Share on other sites More sharing options...
thekiki Posted September 10 Share Posted September 10 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! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted September 10 Share Posted September 10 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! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.