ASMI Posted December 11, 2008 Share Posted December 11, 2008 Ok. This is a bug of 2009. Try this lisp. (defun c:sfind(/ cDiv cDem fStr cSet) (if (and (setq cDiv(getint "\nSpecify dividend: ")) (setq cDem(getint "\nSpecify devider: ")) (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*")) ); end and (progn (if(ssget "_I") (setq cSet(ssget "_I" (list(cons 304 fStr)))) (setq cSet(ssget "_X" (list(cons 304 fStr)))) ); end if (if cSet (progn (sssetfirst nil cSet) (princ(strcat(itoa(sslength cSet)) " found.")) ); end progn (princ "\nNothing found.")) ); end if ); end progn ); end if (princ) ); end of c:sfind It works with all leaders if nothing selected or with selection only. Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 Ok. This is a bug of 2009. Try this lisp. Well that definitely found it. Thank you! Now what do I need to do to globally replace all those fractions with a different one? Is that going to have to be a lisp as well? Because just trying to change the contents only winds up opening each individual mtxt box for each leader. Which means if I have 50+ leaders to replace, it's going to be a while. Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 11, 2008 Share Posted December 11, 2008 Seems works for replacing: (defun c:sreplace(/ cDiv cDem fStr cSet cStr nStr ) (if (and (setq cDiv(getint "\nSpecify dividend: ")) (setq cDem(getint "\nSpecify devider: ")) (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*")) (setq cStr(strcat (itoa cDiv)"#"(itoa cDem))) ); end and (progn (if(ssget "_I") (setq cSet(ssget "_I" (list(cons 304 fStr)))) (setq cSet(ssget "_X" (list(cons 304 fStr)))) ); end if (if cSet (progn (sssetfirst nil cSet) (princ(strcat(itoa(sslength cSet)) " found.")) (if (and (setq nDiv(getint "\nSpecify new dividend: ")) (setq nDem(getint "\nSpecify new devider: ")) ); end and (progn (foreach txt(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp(mapcar 'cadr(ssnamex cSet)))) (vla-put-TextString txt (vl-string-subst(strcat(itoa nDiv) "#"(itoa nDem)) cStr(vla-get-TextString txt))) ); end foreach ); end progn ); end if ); end progn (princ "\nNothing found.") ); end if ); progn ); end if (princ) ); end of c:sreplace Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 "; error: no function definition: nil" That pops up at the end after I specify the changes. And of course, no change occurs. I really need to sit down and begin learning lisps. Thank you for your time on this ASMI. Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 11, 2008 Share Posted December 11, 2008 It can be some error of copyng. Try *.lsp file. sreplace.LSP Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 It can be some error of copyng. Try *.lsp file. I got all excited for a minute, but no, it is still giving the same error. Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 11, 2008 Share Posted December 11, 2008 Ha, ha It most often error. I fogot to include (vl-load-com) function in my code. It should work: (defun c:sreplace(/ cDiv cDem fStr cSet cStr nStr ) (vl-load-com) (if (and (setq cDiv(getint "\nSpecify dividend: ")) (setq cDem(getint "\nSpecify devider: ")) (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*")) (setq cStr(strcat (itoa cDiv)"#"(itoa cDem))) ); end and (progn (if(ssget "_I") (setq cSet(ssget "_I" (list(cons 304 fStr)))) (setq cSet(ssget "_X" (list(cons 304 fStr)))) ); end if (if cSet (progn (sssetfirst nil cSet) (princ(strcat(itoa(sslength cSet)) " found.")) (if (and (setq nDiv(getint "\nSpecify new dividend: ")) (setq nDem(getint "\nSpecify new devider: ")) ); end and (progn (foreach txt(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp(mapcar 'cadr(ssnamex cSet)))) (vla-put-TextString txt (vl-string-subst(strcat(itoa nDiv) "#"(itoa nDem)) cStr(vla-get-TextString txt))) ); end foreach ); end progn ); end if ); end progn (princ "\nNothing found.") ); end if ); progn ); end if (princ) ); end of c:sreplace Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 ASMI.... you're the things that dreams are made of! It works perfectly. Thank you so very much! And my co-worker thanks you as well. Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 .....And my co-worker thanks you as well. Of course as soon as he tries it out he points out that he doesn't have the option of being able to select objects. He's concerned with the global find & replace replacing some of the fractions he won't want replaced.. Like say he's got several leaders with 2 1/3 and several fractions with 1/3 in them, the lisp will currently replace all version of 1/3 regardless of it being 1/3 alone or 2 1/3. I was tempted to tell him "people in..." well nevermind the euphemism the point is, while he thinks the lisp is awesome, he won't use it because he can't be selective about what it selects. ASMI, (or anyone else)if you're still willing to help I'd love to hear your thoughts on it. And I'm beginning to think I should post this in the LISP section of the forums now. Thank you everyone! **tromps off to read the lisp forums and attempt to learn what it is she's looking at** Quote Link to comment Share on other sites More sharing options...
lpseifert Posted December 11, 2008 Share Posted December 11, 2008 **tromps off to read the lisp forums and attempt to learn what it is she's looking at** GQ- have a look here http://www.afralisp.net/ Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 GQ- have a look herehttp://www.afralisp.net/ Ipseifert.. You too are the things dreams are made of. Thank you again! Quote Link to comment Share on other sites More sharing options...
ASMI Posted December 11, 2008 Share Posted December 11, 2008 It seems long story... Try this: (defun c:sreplace(/ cFul cDiv cDem fStr cSet cStr nStr nFul nDiv nDem) (vl-load-com) (setq cFul(getint "\nSpecify full part or Spacebar for none: ")) (if (and (setq cDiv(getint "\nSpecify dividend: ")) (setq cDem(getint "\nSpecify devider: ")) (setq fStr(strcat "*\\A1;" (if cFul(strcat (itoa cFul)" ")"") "{\\H0.7x;\\S" (itoa cDiv) "`#" (itoa cDem)"*")) ); end and (progn (princ "\n<<< Select leaders to replace text >>>") (if(setq cSet(ssget(list(cons 304 fStr)))) (progn (sssetfirst nil cSet) (princ(strcat(itoa(sslength cSet)) " found.")) (setq nFul(getint "\nSpecify new full part or Spacebar for none: ")) (if (and (setq nDiv(getint "\nSpecify new dividend: ")) (setq nDem(getint "\nSpecify new devider: ")) ); end and (progn (foreach txt(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex cSet)))) (vla-put-TextString txt (vl-string-subst (strcat "\\A1;"(if nFul(strcat(itoa nFul)" ")"") "{\\H0.7x;\\S"(itoa nDiv) "#"(itoa nDem)) (vla-get-TextString txt) (vla-get-TextString txt))) ); end foreach ); end progn ); end if ); end progn (princ "\nNothing found.") ); end if ); progn ); end if (princ) ); end of c:sreplace I not can guarantee that it will to work with all your drawings and if improvements you are required can address to me. Quote Link to comment Share on other sites More sharing options...
GypsyQueen Posted December 11, 2008 Author Share Posted December 11, 2008 I not can guarantee that it will to work with all your drawings and if improvements are required you can address to me. Thank ASMI! I'll give it a try and drop you a message if it doesn't work. I'm out of the department at the moment . 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.