Lee Mac Posted June 16, 2015 Share Posted June 16, 2015 Now a days you just pull them from your endless pile of code. Haha! - It'd be no fun if it was that easy Quote Link to comment Share on other sites More sharing options...
Jessifer Posted June 25, 2015 Share Posted June 25, 2015 Hey guys I'm new to this site. I've got a question related to the above find and replace lisp routine. I'm trying to find a specific peace of text as I cycle through my tabs in a drawing yet every time I get to the selection part it prompts me to select the peace of text manually. Is there a way to get the lisp to select text without me clicking on it? I have 115 tabs in a drawing and I am using a routine to go to each tab enter model space through the viewport and set the ucs to the rotation of the text then the viewport to that same ucs, then return to paper space and go to the next tab. (setq ss(ssget)) this sequence requires me to manually select this one below will select automatically but wants me to type my selection... any suggestions to make this automatic??? (initget 1 "1") (setq str (getkword "\nSelect String for filter [1]: ")) (setq ss (ssget "_X" (list (cons 1 (if (eq str "ALL") "*1*" (strcat "*" str "*") ) ) ) ) ) (sssetfirst nil ss) ) Quote Link to comment Share on other sites More sharing options...
Jessifer Posted June 25, 2015 Share Posted June 25, 2015 OK, so I've figured out my find problem with the lisp. I can get it to go through all 115 tabs and rotate to a specific text in each viewport. Now for some reason I'm loosing 1.11 degrees in my rotation after the first tab witch comes in perfect. Any thoughts as to why? Quote Link to comment Share on other sites More sharing options...
jstroebel Posted March 17, 2017 Share Posted March 17, 2017 Great lisp, especially because it finds values that come from fields, is there a way to add a Select feature to the options to select objects with the text string? i.e. [select/Find/Replace/Case/Quit] Quote Link to comment Share on other sites More sharing options...
crazitalk Posted April 10, 2019 Share Posted April 10, 2019 On 3/17/2017 at 3:52 PM, jstroebel said: Great lisp, especially because it finds values that come from fields, is there a way to add a Select feature to the options to select objects with the text string? i.e. [select/Find/Replace/Case/Quit] That's something I've been working on for a bit now. I have a string that occurs multiple times per DWG but I just need to replace a few instances of it where it appears with another string. I'm trying to set it up so that I can run it within a batch scripting routine across multiple DWGs. I've hunted for solutions and haven't found anything online. Here is the latest version I've tried, but it still replaces all instances and not the selected instances. My current best guess is that I can't use vl-string-subst to in combination with a selection set the way I've been trying. (defun c:test (/ OldText NewText SS Count EntList EntText) (if (and (setq OldText (getstring "\nEnter text to replace: ")) (/= OldText "") ) (if (and (setq NewText (getstring "\Enter new text: ")) (/= NewText "") ) (if (setq SS (ssget "X" (list (cons 0 "*TEXT") (cons 1 "BOLTS,*CL*, "))) ) (progn (setq Count 0) (while (< Count (sslength SS)) (setq EntList (entget (ssname SS Count))) (setq EntText (cdr (assoc 1 EntList))) (while (vl-string-search (strcase OldText) (strcase EntText)) (setq EntText (vl-string-subst NewText (strcase OldText) (strcase EntText) ) ) ) (setq EntList (subst (cons 1 EntText) (assoc 1 EntList) EntList) ) (setq EntList (entmod EntList)) (entupd (cdr (assoc -1 EntList))) (setq Count (1+ Count)) ) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
crazitalk Posted April 10, 2019 Share Posted April 10, 2019 After working on this off and on for a few months I've got it doing what I'm needing. The Resulting code currently looks like this: (defun c:test (/ OldText NewText SS Count EntList EntText) (if (and (setq OldText (getstring "\nEnter text to replace: ")) (/= OldText "")) (if (and (setq NewText (getstring "\Enter new text: ")) (/= NewText "")) (if (setq SS (ssget "X" (list (cons 0 "*TEXT") (cons 1 "BOLTS`,*CL*`, *")))) ;The wildcard string in the cons 1 can be changed as needed (progn (setq Count 0) (while (< Count (sslength SS)) (setq EntList (entget (ssname SS Count))) (setq EntText (cdr (assoc 1 EntList))) (while (vl-string-search (strcase OldText) (strcase EntText)) (setq EntText (vl-string-subst NewText (strcase OldText) (strcase EntText)))) (setq EntList (subst (cons 1 EntText) (assoc 1 EntList) EntList)) (setq EntList (entmod EntList)) (entupd (cdr (assoc -1 EntList))) (setq Count (1+ Count))))))) (princ)) I'm going to continue to modify this so that the cons 1 search string is requested from the command line and not hard-coded in. In 4 years of looking I haven't found a routine that does a select-find-replace online. Quote Link to comment Share on other sites More sharing options...
rlx Posted April 10, 2019 Share Posted April 10, 2019 'The Best Text Find And Replace LISP Ever...' , wow , if posted by Master Lee I might have believed it but I think even he would never make such a statement. More something like , this is my best version , so far 4 hours ago, crazitalk said: That's something I've been working on for a bit now. I have a string that occurs multiple times per DWG but I just need to replace a few instances of it where it appears with another string. I'm trying to set it up so that I can run it within a batch scripting routine across multiple DWGs. I've hunted for solutions and haven't found anything online. Here is the latest version I've tried, but it still replaces all instances and not the selected instances. My current best guess is that I can't use vl-string-subst to in combination with a selection set the way I've been trying. How do you imagine letting a script do the selecting for you??? 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.