fleshget Posted October 16, 2009 Share Posted October 16, 2009 hi there, i need a basic lisp about text changing.. the text is: 0+400.652 it change to: 0+700.652 lisp will add 300 some examples here: 0+600.000 -> 0+900.000 0+980.163 -> 1+280.163 there is a big intersection project, and i should add "300" meter to the KM texts.. so hard to doing it :/ sorry for poor english, thanks for advance Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 17, 2009 Share Posted October 17, 2009 This should do it: (defun c:300 (/ ss) (vl-load-com) (if (setq ss (ssget '((0 . "text") (1 . "0+*")))) (foreach str (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) (vla-put-textstring str (strcat "0+" (rtos (+ 300 (atof (substr (vla-get-textstring str) 3))) 2 3)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
stevesfr Posted October 17, 2009 Share Posted October 17, 2009 This should do it: (defun c:300 (/ ss) (vl-load-com) (if (setq ss (ssget '((0 . "text") (1 . "0+*")))) (foreach str (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) (vla-put-textstring str (strcat "0+" (rtos (+ 300 (atof (substr (vla-get-textstring str) 3))) 2 3)) ) ) ) (princ) ) Not quite: 0+700 does not change to 1+000, but instead changes to 0+1000 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 17, 2009 Share Posted October 17, 2009 Not quite: 0+700 does not change to 1+000, but instead changes to 0+1000 That's what I get for writing code @ 3 in the morning... Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 17, 2009 Share Posted October 17, 2009 Ok....I've had my coffee and this appears to work (defun c:incsta (/ int isreal lst newstr pos ss string) (vl-load-com) (if (setq ss (ssget ":L" '((0 . "text") (1 . "*+*"))) int (getint "\nEnter increment amount: ") ) (foreach str (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) (setq string (vla-get-textstring str) lst (vl-string->list string) newstr (rtos (+ int (atof (apply 'strcat (mapcar 'chr (vl-remove 43 lst))))) 2 (if (setq isreal (vl-string-position 46 string)) (strlen (substr string (+ 2 isreal))) 0 ) ) pos (abs (+ (vl-string-position 43 string) (- (1+ (strlen newstr)) (strlen string))) ) newstr (strcat (substr newstr 1 pos) "+" (substr newstr (1+ pos))) newstr (strcat (if (wcmatch newstr "+*") "0" "" ) newstr ) ) (vla-put-textstring str newstr) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
fleshget Posted October 17, 2009 Author Share Posted October 17, 2009 you save me from "3 days work". thanks so so so much for helping me! you made my day bro! e-beer for you cheers bro! EDIT: hay mate, there is a problem.. how to use this lisp? enter the command, and select the text(s), enter the encrement amount and then? i'm using 2010 right now, and command bar says to me: Command: incsta Select objects: Specify opposite corner: 2 found Select objects: Enter increment amount: 500 Pick a point to increment selected text: ; error: bad argument value: non-negative: -2 the text is: 60+380.000 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 17, 2009 Share Posted October 17, 2009 .....EDIT: hay mate, there is a problem.. how to use this lisp? enter the command, and select the text(s), enter the encrement amount and then? i'm using 2010 right now, and command bar says to me: Command: incsta Select objects: Specify opposite corner: 2 found Select objects: Enter increment amount: 500 Pick a point to increment selected text: ; error: bad argument value: non-negative: -2 the text is: 60+380.000 Thanks for the E-Beer ... can you post the drawing you are working in? I tried that text string and it worked fine? *EDIT....I think I may have fixed it...I reposted the code above. Give it a try and let me know. Quote Link to comment Share on other sites More sharing options...
fleshget Posted October 18, 2009 Author Share Posted October 18, 2009 i tried right now mate.. 60+380.000 to 60+480 60+380.001 to 60+480.001 the problem is ".000", i guess.. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 18, 2009 Share Posted October 18, 2009 i tried right now mate.. 60+380.000 to 60+480 60+380.001 to 60+480.001 the problem is ".000", i guess.. I cannot duplicate your problem.... post your drawing and I'll try to get it sorted. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 22, 2009 Share Posted October 22, 2009 I guess all is well with this? Quote Link to comment Share on other sites More sharing options...
stevesfr Posted October 22, 2009 Share Posted October 22, 2009 I guess all is well with this? INCSTA will only allow addition of whole number, i.e. 3 or 50 etc. will not accept 3.100, or 50.1 etc. I guess if the OP only wants to change by whole number not including any decimal part, then so be it. I'd like the opportunity to change by any value. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 22, 2009 Share Posted October 22, 2009 INCSTA will only allow addition of whole number, i.e. 3 or 50 etc.will not accept 3.100, or 50.1 etc. I guess if the OP only wants to change by whole number not including any decimal part, then so be it. I'd like the opportunity to change by any value. Change: (getint "\nEnter increment amount: ") to (getreal "\nEnter increment amount: ") or (getdist "\nEnter increment amount: ") and it should work. Quote Link to comment Share on other sites More sharing options...
stevesfr Posted October 22, 2009 Share Posted October 22, 2009 Change: (getint "\nEnter increment amount: ") to (getreal "\nEnter increment amount: ") or (getdist "\nEnter increment amount: ") and it should work. Yes sir, it worked fine. Didn't dawn on this old head Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 22, 2009 Share Posted October 22, 2009 Yes sir, it worked fine. Didn't dawn on this old head Glad it was an easy fix 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.