Jump to content

Recommended Posts

Posted

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.

Posted (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 by BIGAL
  • Thanks 1
Posted (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.png

replace.lsp

image.png

Edited by Nikon
  • Like 1
Posted
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

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