Lisp needed for select specific text objects

Lisp needed for select specific text objects

Sandervp
Advocate Advocate
8,273 Views
9 Replies
Message 1 of 10

Lisp needed for select specific text objects

Sandervp
Advocate
Advocate

Hello everybody,

 

Because I have a lot of drawings whit a lot of "dirt', I need to "clean up" first. That's why I am searching for a lisp that will find different text or mtext objects for me which contains the same letter/ number or text string (/part of a word, like *Auto* from "AutoCad").

 

Quickselect is an option to find these objects and also filter is a sollution. But I want something simple. No window where you have to select several things first. It takes a lot of time to find

 

What I want looks like (for example) the -layer command. You'll get a lot of options first and if you have chosen one, you can chose again.

 

 

If the qselect command also have a -qselect option; my macro should look like this;

 

^C^C_-qselect;all;text;contents;

At last I need to give the number/ letter or text string where I'm looking for or select an text object with the text I want to select.

 

Is there somebody who can help me?

 

Thank you

 

 

 

 

0 Likes
Accepted solutions (1)
8,274 Views
9 Replies
Replies (9)
Message 2 of 10

Patchy
Mentor
Mentor

Go to lee-mac.com and look for Bfind.lsp in the free section.

0 Likes
Message 3 of 10

Sandervp
Advocate
Advocate
Hello Patchy,

Bfind.lsp is not a sollution......

It tooks my whole directory. I was a little bit too fast.

I have to make everything undone using my .bak files.
0 Likes
Message 4 of 10

Patchy
Mentor
Mentor

There is a box for SEARCH ONLY in the dialog box and there is option for current drawing.

0 Likes
Message 5 of 10

Kent1Cooper
Consultant
Consultant

Here's a [in simplest terms and minimally tested] way:

 

(defun C:FSC (/ str ss) ; = Find String(s) by Content
  (setq str (getstring "\nYour [full or partial] string content to search for: "))
  (if (setq ss (ssget "_X" (list (cons 0 "*TEXT") (cons 1 (strcat "*" str "*")) (cons 410 (getvar 'ctab)))))
    (sssetfirst nil ss); select/highlight/grip
  ); if
); defun

 

It could be enhanced, apart from the usual error-handling and other typical controls:

 

It could be made not case-sensitive [the above is case-sensitive].

It could be made to also find Attribute Definitions and Dimensions with the desired string as part of override text content, by leaving out the (cons 0 "*TEXT") part.

[Attributes in Blocks are another matter and more complicated, but are also possible.]

It could be made to find such strings anywhere in the drawing, by leaving out the (cons 410 (getvar 'ctab)) part, but would not be able to select/highlight/grip those not in the current space.

 

EDIT --  Looking back at the original question:  On the subject of "...or select an text object with the text I want to select...", that could be incorporated, but in basic form it would find only other objects containing the entire content of the selected object, though it could be made to also find those that may have additional content before and/or after that.  But I can imagine an approach that could accept a selected object and offer the chance to pare its content down to some portion of it, and search for that in other objects.  Would that be desirable?

Kent Cooper, AIA
Message 6 of 10

Sandervp
Advocate
Advocate

Hello Kent Cooper,

 

 

Thanks for your lisp!

 

It's working on text strings, but is there also a possibility to change this lisp so it could also finds numbers or letters only?

For example; If I want to select al the text objects containing the "a" or "7" only? Instead a word containing the letter "a".

 

 

0 Likes
Message 7 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@svpelt wrote:

.... 

It's working on text strings, but is there also a possibility to change this lisp so it could also finds numbers or letters only?

For example; If I want to select al the text objects containing the "a" or "7" only? Instead a word containing the letter "a".


For the User's input to be the entire string, rather than just a substring, change this part:

 

  (cons 1 (strcat "*" str "*"))

 

to just this:

 

  (cons 1 str)

 

The asterisks are wildcards for any amount of [including none] additional content before and/or after the specified sub-string.

 

It will find single characters as in your examples if that's what the User supplies, but accepts strings of any length.

 

[Also change the prompt to something more like:  "\nYour full string to search for: "]

Kent Cooper, AIA
Message 8 of 10

Sandervp
Advocate
Advocate

Thanks again Kent!!

 

I have changed (cons 1 (strcat "*" str "*")) into  (cons 1 str) and it works! It will find the whole words or letters/numbers were I'm looking for!

 

This will help me a lot!

 

It will save a lot of time also, instead using quick select every time!

 

 

Thanks!!

0 Likes
Message 9 of 10

paliwal222
Advocate
Advocate

HELLO, Thanks very much for that but i want to pick on a text instead of type it.

0 Likes
Message 10 of 10

joe.jamal7991
Explorer
Explorer

Great answer, it really helped a lot ...

I`m just wondering if we could really enhance the script a little bit to select the nearest line to the specific Texts we searched for already because I searched for such lisp and I didn`t find one, Would Really appreciate your help.

0 Likes