Hi all,
I'm looking for a lisp that will allow me to select all text on a personnel layer and change all the text to the same word. Ex. I have "100 different personnel names" and I'd like to change all of them to say"WS". Is this possible?
Solved! Go to Solution.
Solved by ronjonp. Go to Solution.
Sure:
(defun c:foo (/ s)
(if (setq s (ssget ":L" '((0 . "TEXT") (8 . "personnel"))))
(foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
(entmod (append (entget e) '((1 . "WS"))))
)
)
(princ)
)
Or for no selection needed:
(defun c:foo (/ s)
(if (setq s (ssget "_X" '((0 . "TEXT") (8 . "personnel"))))
(foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) '((1 . "WS")))))
)
(princ)
)
This can also be accomplished by using a little snippet like this and changing whatever property you'd like in the properties palette.
(sssetfirst nil (ssget "_X" '((0 . "TEXT")(8 . "personnel"))))
Or use the FILTER command. Many ways to skin this cat.
Another approach, posted mostly because it also includes Mtext if you need that:
(defun C:TEST (/ ss n)
(if (setq ss (ssget "_X" '((0 . "*TEXT") (8 . "YourLayerName"))))
(repeat (setq n (sslength ss))
(vla-put-TextString (vlax-ename->vla-object (ssname ss (setq n (1- n)))) "WS")
)
)
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.