soan Posted January 27, 2016 Share Posted January 27, 2016 (edited) Hi, I look for a LISP that I can not find anywhere on. 1- The first text i will selected, it will find the text "XX" and automatically replace by the number "01" 2- The second text i will selected, it will find the text "XX" and automatically replace by the number "02" 3- Continue step 1 & 2 (number "03", "04", "05"...) until i stop the LISP 4- I don't have to choose which text i want to replace when i open LISP (always the word "XX") and don't choose the first number (always the number "01") I hope you undertand me (i'm a french canadians ) Thanks a lot !!! Edited January 27, 2016 by soan Quote Link to comment Share on other sites More sharing options...
ketxu Posted January 28, 2016 Share Posted January 28, 2016 Im thinking about Tcount command in express tool ^^ Quote Link to comment Share on other sites More sharing options...
soan Posted January 28, 2016 Author Share Posted January 28, 2016 Hello, Thank you for the quick response! The Tcount command does not select a block at a time and you have to configure the settings each time. It is faster to change each device number to hand that used the Tcount command. Quote Link to comment Share on other sites More sharing options...
Cad64 Posted January 28, 2016 Share Posted January 28, 2016 Soan, this is the 2nd time I have had to move one of your questions to the Autolisp section. Please post your lisp questions here: http://www.cadtutor.net/forum/forumdisplay.php?21-AutoLISP-Visual-LISP-amp-DCL Quote Link to comment Share on other sites More sharing options...
soan Posted January 28, 2016 Author Share Posted January 28, 2016 I'm sorry, i post two questions the same day and its my first time on the site... Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 29, 2016 Share Posted January 29, 2016 (edited) Its an easy task but I am short of time right now pick text check if "XX" exist using wcmatch then read string up to xx add number. Found some time. ; replace XX with a number ; By Alan H jan 2016 (defun c:add01 ( / obj ans x newstr) (setq x (getint "\nEnter start number press <Cr> to exit ")) (while (/= (setq obj (vlax-ename->vla-object(car (entsel "\nPick text")))) nil) ; no errork check for text ; if less than 10 01-09 10+ (if (< x 10.0) (setq newstr (strcat "0" (rtos x 2 0))) (setq newstr (rtos x 2 0)) ) (setq txtstr (vla-get-textstring obj)) ;return string val (if (> (setq pos (vl-string-search "XX" (strcase txtstr))) 1) ; return the position of XX (progn (setq num (strlen txtstr)) ; how many caharcters is string re abcdexxhjkl problem (setq ans (Strcat (substr txtstr 1 pos) newstr)) ; combine characters up to xx+01 ) ) (vla-put-textstring obj ans) ; update text (setq x (+ x 1)) ; next number ) (princ) ) Edited January 30, 2016 by BIGAL Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 30, 2016 Share Posted January 30, 2016 Code updated now, only question is if you have abcdXX-52-b it will do abcd08 etc needs a version 2 that checks for end of line characters, Soan if needed have a go the code is there. Quote Link to comment Share on other sites More sharing options...
soan Posted February 1, 2016 Author Share Posted February 1, 2016 Thanks a lot for your response, to answer your question, I need version 2. Thank you for your help is much appreciated Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 2, 2016 Share Posted February 2, 2016 Soan if needed have a go the code is there. We are here to help (strlen "abcdxx1234") returns 10, (substr txtstr 7 10) ="1234" 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.