Sooshiant Posted August 30 Posted August 30 Hello everyone I need a Lisp that converts the contents of one or more separate texts (not MTEXT) to another text. Suppose that there are discrete texts in different places of the layout, for example, apple, orange, banana, lemon. I need a lisp that after typing the command, I do the first right click on the apple, and by doing the rest of the right clicks on other fruits, they turn into apples. Thank you for your help. Quote
BIGAL Posted August 30 Posted August 30 (edited) It is a simple task to replace a new string in an existing string, the issue here is Mtext can have multiple lines of text, is your mtext only 1 line ? Also it can have various controls in the text font style, color, bold and so on. Please confirm or post a sample dwg may be best use wblock to make a small dwg if necessary. This is for just single text no mtext controls. (defun c:test ( / obj ent txt) (setq obj (vlax-ename->vla-object (car (entsel "\nSelect a text object ")))) (setq txt (vlax-get obj 'textstring)) (while (setq ent (car (entsel "\nPick text to change Enter to exit "))) (vlax-put (vlax-ename->vla-object ent) 'textstring txt) ) (princ) ) Edited August 31 by BIGAL 1 Quote
Nikon Posted August 31 Posted August 31 (edited) Suppose that there are discrete texts in different places of the layout, for example, apple, orange, banana, lemon. I need a lisp that after typing the command, I do the first right click on the apple, and by doing the rest of the right clicks on other fruits, they turn into apples. Lisp will replace any number of selected texts with "apple" (for example)... First, select the replacement texts, and then specify the sample text. replace.lsp Edited August 31 by Nikon 1 Quote
Sooshiant Posted August 31 Author Posted August 31 17 hours ago, BIGAL said: It is a simple task to replace a new string in an existing string, the issue here is Mtext can have multiple lines of text, is your mtext only 1 line ? Also it can have various controls in the text font style, color, bold and so on. Please confirm or post a sample dwg may be best use wblock to make a small dwg if necessary. This is for just single text no mtext controls. (defun c:test ( / obj ent txt) (setq obj (vlax-ename->vla-object (car (entsel "\nSelect a object ")))) (setq txt (vlax-get obj 'textstring)) (while (setq ent (car (entsel "\nPick text to change Enter to exit "))) (vlax-put (vlax-ename->vla-object ent) 'textstring txt) ) (princ) ) That's great you are genius, thank you very much Quote
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.