MikeP Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
eldon Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2010 Share Posted October 19, 2010 Note - This will not handle wildcards. Yes it will Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 Yes it will lmao... ohh, yeah! I have too many things going on right now. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2010 Share Posted October 19, 2010 I think Mike doesn't realise that he'll have to use a wildcard to search for a word within a string. Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 (edited) 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 October 19, 2010 by BlackBox Edited getstring call Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2010 Share Posted October 19, 2010 what is a wild card and how would i use it with the FOO command Read the Help Files on wcmatch Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2010 Share Posted October 19, 2010 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) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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 = "" ...? Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 19, 2010 Share Posted October 19, 2010 I appreciate the elegance of your routine, but what about getstring = "" ...?Look a little closer. Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 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" Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 19, 2010 Share Posted October 19, 2010 Out of curiosity, is your (1)...(4) example one piece of MText or separate (M)Text objects? Quote Link to comment Share on other sites More sharing options...
MikeP Posted October 19, 2010 Author Share Posted October 19, 2010 sorry, yeah they are 4 different single line text objects Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.