`LISP MODIFICATION

`LISP MODIFICATION

inaamazmi
Enthusiast Enthusiast
357 Views
3 Replies
Message 1 of 4

`LISP MODIFICATION

inaamazmi
Enthusiast
Enthusiast

I have a lisp that add prefix and suffix to existing text but the problem is adding prefix in the same line i want to add prefix as a diffrent line..see the sample drawing 

 

lisp code

;prefix and suffix selected Texts
;(C) CAD Studio - www.cadstudio.cz
;
(defun C:PSfixTxt (/ ss ssl obj sPrefix sSuffix)
(vl-load-com)
(princ "\nSelect Texts, Mtexts, MLeaders: ")
(setq ss (ssget '((0 . "TEXT,MTEXT,MULTILEADER")))
sPrefix (getstring "\nEnter prefix: " T)
sSuffix (getstring "\nEnter suffix: " T)
)
(setq ssl (sslength ss))
(repeat ssl
(setq ssl (1- ssl))
(setq obj (vlax-ename->vla-object (ssname ss ssl)))
(vla-put-textstring obj (strcat sPrefix (vla-get-textstring obj) sSuffix))
)
(prin1)
)

0 Likes
358 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

The lisp works perfectly fine. If you need another line, YOU need to add the return character too.

 

SERVICE DUCT\P

 

BeekeeCZ_0-1672483140556.png

 

Of course, this applies to MTEXTs and multiline ATTS only.

0 Likes
Message 3 of 4

inaamazmi
Enthusiast
Enthusiast

How?

0 Likes
Message 4 of 4

calderg1000
Mentor
Mentor

Regards @inaamazmi 

Here I give you the idea to modify the Mtext.
Edit the code that you attach, so that it works only with prefixes and with texts of the same number of characters.

It works with Mtext, Text can't be stacked in columns unless you convert it to Mtex

 

(defun C:PSfixTxt (/ ss ssl obj tx sSuffix)
(vl-load-com)
(princ "\nSelect Mtexts, MLeaders: ")
(setq ss (ssget '((0 . "MTEXT,MULTILEADER"))))
(SETQ sSuffix (getstring "\nEnter suffix: " T)
)
(setq ssl (sslength ss))
(repeat ssl
(setq ssl (1- ssl))
(setq obj (vlax-ename->vla-object (ssname ss ssl)))
(setq tx(vla-get-textstring obj))
(vla-put-textstring obj (strcat (substr tx 1 12) "\\P" (substr tx 13)
 "\\P" sSuffix))
)
(prin1)
)

 

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes