Originally Posted by
mohammad.raees637333
My query is that I want to replace the value of a pre decided string to a single string by clicking on it. Find and replace is not useful for this because it replaces all strings. For example in autocad drawing any text is given and by clicking on this text it should be replaced by pre decided text "xyz" (for example).
I am unsure if you intentionally requested to select each-and-every-single text entity one-at-a-time or not, so this will allow you to do that, or select multiple text entities at once:
Code:
(defun c:FOO (/ *error* acDoc)
(defun *error* (msg)
(if acDoc (vla-endundomark acDoc))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if (ssget "_:L" '((0 . "TEXT,MTEXT")))
(progn
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vlax-for x (vla-get-activeselectionset acDoc)
(vla-put-textstring x "xyz")
)
)
)
(*error* nil)
)