@S_S_SS wrote:
.... by selecting the text or mtext and press "st" then it select all the text or mtext that contain the same content ....
The QSELECT, FILTER and FIND suggestions ignore that part, and require you to feed in the content*, rather than getting it from an object you select. Try this [lightly tested]:
(defun C:ST (/ tss tsel tdata); = Select Text [with same contents]
(if
(or
(and
(setq tss (ssget "_I" '((0 . "*TEXT")))); [M]Text among pre-selection
(= (sslength tss) 1); only one
(setq tdata (entget (ssname tss 0)))
); and
(and
(not (sssetfirst)); clear pre-selection if any
(setq tsel (entsel "\nSelect [M]Text to find all with the same contents: "))
(setq tdata (entget (car tsel)))
(wcmatch (cdr (assoc 0 tdata)) "*TEXT")
); and
); or
(sssetfirst nil (ssget "_X" (list '(0 . "*TEXT") (assoc 1 tdata)))); then
(prompt "\nYou must select one Text or Mtext object."); else
); if
)
It works either with or without pre-selection [noun-verb or verb-noun operation]. If a pre-selection includes one Text/Mtext object [whether or not it also includes any other kind(s) of object(s)], it uses the content of that. If a pre-selection contains no Text/Mtext objects or more than one, it clears the selection and asks you to select one, the same as if you entered the command with no pre-selection. If there is no pre-selection, it simply asks you to select one.
If the source is Mtext with any internal formatting, it will find others with exactly the same internal formatting, but not plain Text or un-formatted Mtext with otherwise the same content. If the source is plain Text or un-formatted Mtext, it finds both Text and un-formatted Mtext objects with the same content.
It's case-sensitive.
* There is a way to get the content in FILTER from a selected object, but you then need to weed out all other properties of that object that you want ignored from the filter list. The "Text" object you can include covers both Text and Mtext [Mtext is not in the list], and I find if I don't include that, but only the "Text value" entry, it will also find things like Dimensions with that content as a text override.
Kent Cooper, AIA