Jump to content

need a lisp thats similar to the find command


MikeP

Recommended Posts

what i need to do is use the find command, but not to find/replace text. I need it to search my entered text and select it so that i can come along and change the color after. If it can use the same "FIND" interface that would be awesome.

Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • MikeP

    12

  • BlackBox

    10

  • alanjt

    6

  • Lee Mac

    4

Popular Days

Top Posters In This Topic

Have you explored the whole of the FIND command, including the Zoom To option?

 

Perhaps you may well find that you do not actually need someone to write a lisp for you when there is a built in AutoCAD function.

Link to comment
Share on other sites

Have you explored the whole of the FIND command, including the Zoom To option?

 

Perhaps you may well find that you do not actually need someone to write a lisp for you when there is a built in AutoCAD function.

 

 

no i still need everything selected once i leave the command. the find command alone is not able to do that.

Link to comment
Share on other sites

Will something like this work:

 

(defun c:FOO (/ text ss)
 (if (and (setq text (getstring T "\n  >>  Enter Text To Find: "))
          (setq ss (ssget "_x" (list '(0 . "TEXT,MTEXT") (cons 1 text)))))
   (sssetfirst nil ss))
 (princ))

 

 

Note - This will not handle wildcards.

 

Hope this helps!

Link to comment
Share on other sites

it works. its almost there though. 2 things its not doing. I need to only search within my selection set, not the entire drawing. and I need it to be able to search a text object and find a word or words with in the text. It can select the entire text object though. I need it because I have a large group of parts layed out on my drawing. each part has a description and group number. I need to be select every part with a certain group number.

 

and maybe it can also tell me how many was found.

 

I appreciate your help though

Link to comment
Share on other sites

it works. its almost there though. 2 things its not doing.

 

 

This may be because I having a lot going on, but I'm confused....

 

I need to only search within my selection set, not the entire drawing.

 

 

The code I posted creates a selection set of only items that meet the filter criteria (i.e., match your text string).

 

What selection set are you referring to... you mean that you want to pass a selection set to this function (i.e., (FOO ss) )?

 

and I need it to be able to search a text object and find a word or words with in the text. It can select the entire text object though. I need it because I have a large group of parts layed out on my drawing. each part has a description and group number. I need to be select every part with a certain group number.

 

 

Again, I must be missing something, if the description and group number aren't the same this shouldn't pose an issue.

 

Does the group number text happen to be on it's own layer, by chance? If so, then we could revise the filter criteria.

 

Let me know.

Link to comment
Share on other sites

I might just be explaining it bad. I want to be able to select a group of text objects. these text objects are name and description of a part that i have. There may be 5 groups that i have but a different hundred parts in total. Rather than me manually panning around my window and reading each group number to find the specific part within that group that im looking for. I would like to be able to select the parts and use the FOO command and enter only the group number. For example a description text object would look like this. "1.01 Right side" I have "2.1 Right side", "3.1 Right Side". but i only wanna find everything that include under "1.01"

 

what is a wild card and how would i use it with the FOO command

Link to comment
Share on other sites

Given the format you listed, perhaps this revision will work:

 

(defun c:FOO (/ text ss)
 (if (and (/= "" (setq text (getstring T "\n  >>  Enter Group Number: ")))
          (setq ss (ssget "_x" (list '(0 . "TEXT,MTEXT") (cons 1 (strcat text "*"))))))
   (sssetfirst nil ss)
   (prompt "\n  <!>  Nothing Selected  <!> "))
 (princ))

Edited by BlackBox
Edited getstring call
Link to comment
Share on other sites

no searching only within my selection of objects. Its looking at the entire drawing. and it can only find it if the entire text is that i type cant search within the text

Link to comment
Share on other sites

Here's how I might approach it

 

(defun c:find2 nil
 (sssetfirst nil
   (ssget
     (list (cons 0 "MTEXT,TEXT")
       (cons 1 (strcat "*" (getstring "\nText to Find <All>: ") "*"))
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

no searching only within my selection of objects. Its looking at the entire drawing. and it can only find it if the entire text is that i type cant search within the text

 

I must be going silly today, but what are you talking about?

 

Not that my code is correct (because obviously it's not working for you), but I am having a hard time understanding you (please be patient).

 

So you want to (manually) select a group of text entities, then enter the group code, then filter them for the group code criteria?

 

Edit:

I just saw Lee's post while writing this, perhaps the only thing missing was the preceding "*" in the filter criteria.

Link to comment
Share on other sites

Here's how I might approach it

 

(defun c:find2 nil
 (sssetfirst nil
   (ssget
     (list (cons 0 "MTEXT,TEXT")
       (cons 1 (strcat "*" (getstring "\nText to Find <All>: ") "*"))
     )
   )
 )
 (princ)
)

 

I appreciate the elegance of your routine, but what about getstring = "" ...?

Link to comment
Share on other sites

Lee mac's code does closer to that im looking. Its allowing me to select a group that i want to search in. but it will only find it if the desired text is equal to the entire context of a text block.

 

 

 

(1) 1.02 Base Back Thick 34.8975 x 12.86

(2) 1.01 Base Back Thick 34.8975 x 12.86

(3) 1.02 Base Back Thick 34.8975 x 12.86

(4) 1.01 Base Back Thick 34.8975 x 12.86

 

lets just say the above is an example of the text objects im trying to search through. the "1.01" group is the only group I am looking for.

 

I want to be able to type in "1.01" and it should highlight only whats in red.

 

(1) 1.02 Base Back Thick 34.8975 x 12.86

(2) 1.01 Base Back Thick 34.8975 x 12.86

(3) 1.02 Base Back Thick 34.8975 x 12.86

(4) 1.01 Base Back Thick 34.8975 x 12.86

 

yet it will only highlight something if i enter "(1) 1.02 Base Back Thick 34.8975 x 12.86"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...