Change Text String HELP PLEASE!!!

Change Text String HELP PLEASE!!!

Anonymous
Not applicable
1,000 Views
5 Replies
Message 1 of 6

Change Text String HELP PLEASE!!!

Anonymous
Not applicable

I want to change the contents of all text found on a certain layer.  There are hundreds of individual text items all on the same layer, all different contents.  I want to change every one to the same thing "Test"  In the picture below I want the text "065-4, 065-5, 065-6" all changed to "test"text example.jpg

0 Likes
Accepted solutions (2)
1,001 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

I can get a selection set of all text on that layer, but is there a variable for "contents".  if I select them all and go to properties, I can change it there, but I need to do this through lisp.

0 Likes
Message 3 of 6

Ranjit_Singh
Advisor
Advisor
Accepted solution

Try below code. Minimal testing

(defun c:somefunc  (/ etdata)
 (mapcar '(lambda (x) (setq etdata (entget x)) (entmod (subst (cons 1 "Text") (assoc 1 etdata) etdata)))
         (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "*text") (8 . "0")))))));replace "0" with your layer name

REPLACE_ALL_TEXT_MTEXT.gif

 

Message 4 of 6

Anonymous
Not applicable

Looks like it works perfect.  What do I change if I want it to apply the change to a selection set (name of selection set is "SS10")?

Thank you!

0 Likes
Message 5 of 6

Ranjit_Singh
Advisor
Advisor
Accepted solution

Below will allow you to pick entities on screen

(defun c:somefunc  (/ etdata)
 (mapcar '(lambda (x) (setq etdata (entget x)) (entmod (subst (cons 1 "Text") (assoc 1 etdata) etdata)))
         (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "*text") (8 . "0"))))))));replace "0" with your layer name

If you wish to pass a global variable SS10 then this will work

(defun c:somefunc  (/ etdata)
 (mapcar '(lambda (x) (setq etdata (entget x)) (entmod (subst (cons 1 "Text") (assoc 1 etdata) etdata)))
         (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss10)))));replace "0" with your layer name

 

 

Message 6 of 6

Anonymous
Not applicable

Thank you for your help and quick response to questions!!!  works PERFECT.

0 Likes