mfadzli Posted July 16, 2014 Share Posted July 16, 2014 hi all I need some lisp that will increment text like this.. 1R 1Y 1B 2R 2Y 2B 3R 3Y 3B...:) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 21, 2014 Share Posted July 21, 2014 hi mfadzli no people respond because people not understand ? ? can you explain clearly or try other thread here http://www.cadtutor.net/forum/showthread.php?79801-Increment-numbers....but-with-special-thing. . Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 22, 2014 Share Posted July 22, 2014 Understand what you want can you elaborate a bit more is it TEXT or Mtext, is it on one layer only. You can get all the text search for the 1st apha character then find the highest number add 1 and add text. Post a dwg for testing. As the quantity of text increases if not on one layer it may mean slight hesitation bewteen each one. Quote Link to comment Share on other sites More sharing options...
mfadzli Posted July 22, 2014 Author Share Posted July 22, 2014 Sorry for that simple question..hehe.. I'm looking for a lisp to increment Text For example i have text "01" "02" "03" "04" "05" "06" need to replaced with "01R" "01Y" "01B" "02R" "02Y" "02B". Just pick the text and it will replace and follow the sequence as above example. For example see attached file. Sample.dwg Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 22, 2014 Share Posted July 22, 2014 (edited) Sorry for that simple question..hehe.. I'm looking for a lisp to increment Text For example i have text "01" "02" "03" "04" "05" "06" need to replaced with "01R" "01Y" "01B" "02R" "02Y" "02B". Just pick the text and it will replace and follow the sequence as above example. For example see attached file. i try to figure out: does it mean 9= "03B"? 28= "10R"? 38= "13Y"? if i'm right, then you can try the code below, command: BRY select Text or Mtext ;Add incremental suffix B R Y ;hp# 22/07/14 ;http://www.cadtutor.net/forum/showthread.php?87667-Need-some-lisp... (defun C:BRY (/ *error* e tx #) (defun *error* (msg) (if (wcmatch (strcase msg) "*CANCEL*,*EXIT*") (princ msg) (princ (strcat "\n*Error: " msg)) ) ) (while (setq e (entsel "\nSelect *TEXT: ")) ; *edited thanx mr.Tharwat (if (and (setq e (car e)) (setq tx (cdr (assoc 1 (entget e)))) (/= (setq # (atof tx)) 0) ;(not (wcmatch (strcase tx) "*B,*R,*Y")) ; *removed (numberp(read tx)) ; *added ) (vla-put-textstring (vlax-ename->vla-object e) ('((# / i n) (setq n (fix (abs #)) i (rem n 3.)) (strcat (if (minusp #) "-" (if (< n 10) "0" "")) (rtos (if (zerop i) (/ n 3.) (1+ (fix (/ n 3.)))) 2 0) (cond ((zerop i) "B") ((= i 1) "R") ((= i 2) "Y")))) #))))) (princ "command: BRY") (princ) Edited July 24, 2014 by hanhphuc (while (/= (setq e... ) nil) ... ; thanx mr.Tharwat Quote Link to comment Share on other sites More sharing options...
mfadzli Posted July 22, 2014 Author Share Posted July 22, 2014 wow...thanks hanhphuc...you are awesome...this is what i want.. thanks for help.. i think i need to learn lisp from now...hehe.. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 23, 2014 Share Posted July 23, 2014 wow...thanks hanhphuc...you are awesome...this is what i want..thanks for help.. i think i need to learn lisp from now...hehe.. you are welcome i edit a bit which i replaced: (not (wcmatch (strcase tx) "*B,*R,*Y")) to: (numberp(read tx)) ie: It only works on numeric text, eg:01,02,03 so it won't mass up "kacau" alphabetic text eg:ABC,03X,P123, etc.. Quote Link to comment Share on other sites More sharing options...
mfadzli Posted July 23, 2014 Author Share Posted July 23, 2014 you are welcome i edit a bit which i replaced: (not (wcmatch (strcase tx) "*B,*R,*Y")) to: (numberp(read tx)) ie: It only works on numeric text, eg:01,02,03 so it won't mass up "kacau" alphabetic text eg:ABC,03X,P123, etc.. wow...thanks for that... you can speak malay? hehe Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 23, 2014 Share Posted July 23, 2014 sorry this forum is for CAD & LISP topic hehe i assumed you are Singaporean or Malaysian bcos they used to say "..lah" "..hehe" "..meh" etc.. i agree with @BIGAL: elaborate a bit more, there are a lot of distinguished gurus can help you too, who i also need their guide too Quote Link to comment Share on other sites More sharing options...
pBe Posted July 23, 2014 Share Posted July 23, 2014 i try to figure out:does it mean 9= "03B"? 28= "10R"? 38= "13Y"? How'd you come up with that hanhphuc? Can you explain it to the rest of us. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 23, 2014 Share Posted July 23, 2014 How'd you come up with that hanhphuc? Can you explain it to the rest of us. The pattern is sequence remainder of 3, to suffix R,Y,B Quote Link to comment Share on other sites More sharing options...
samifox Posted July 23, 2014 Share Posted July 23, 2014 There is num lisp in the exress tools Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 23, 2014 Share Posted July 23, 2014 (while (/= (setq e (entsel "\nSelect *TEXT: ")) nil) FYI , if a user selected any object (e.g TEXT in this routine ) it would return a value which is does not mean equal to nil at all , so to check for not equal to nil is not needed . Quote Link to comment Share on other sites More sharing options...
pBe Posted July 23, 2014 Share Posted July 23, 2014 The pattern is sequence remainder of 3, to suffix R,Y,B Good stuff hanhphuc. Thank you for the info Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted July 24, 2014 Share Posted July 24, 2014 FYI , if a user selected any object (e.g TEXT in this routine ) it would return a value which is does not mean equal to nil at all , so to check for not equal to nil is not needed . oops.. mr.Tharwat you are correct: (while T... ), your (esp senior members) comments, guide, debug etc.. are very appreciated in order i can improve learning from mistake. Thanks again cheers @pBe: you are welcome Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 24, 2014 Share Posted July 24, 2014 oops.. mr.Tharwat you are correct: (while T... ),your (esp senior members) comments, guide, debug etc.. are very appreciated in order i can improve learning from mistake. Thanks again cheers It's kind of you to say that , and you're welcome. 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.