lucky9 Posted June 20, 2018 Share Posted June 20, 2018 Need a code that can increment 1 number with a prefix. For example Enter prefix > J- Enter number to start > 4 Now, with every click anywhere on a drawing it should make a text with prefix as following J-4 , J-5 , J-6 .. etc Thanks Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 20, 2018 Share Posted June 20, 2018 (defun C:test ( / pref suff i h p s ) (setq pref (getstring "Enter prefix <continue>: ")) (setq suff (getstring "Enter suffix <continue>: ")) (setq i (1- (cond ((progn (initget 4) (getint "Enter number to start <0>: ")))(0)))) (setq h (getvar 'textsize)) (while (setq p (getpoint (strcat "\nSpecify " (setq s (strcat pref (itoa (setq i (1+ i))) suff)) " location <done>: "))) (entmakex (list '(0 . "TEXT") (cons 10 p) (cons 40 h) (cons 1 s))) ) (princ) ); defun Quote Link to comment Share on other sites More sharing options...
rlx Posted June 20, 2018 Share Posted June 20, 2018 jolly good show old chap Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 20, 2018 Share Posted June 20, 2018 jolly good show old chap Thanks! Now I'm finding this idea useful for myself. Quote Link to comment Share on other sites More sharing options...
asos2000 Posted June 20, 2018 Share Posted June 20, 2018 Try this http://lee-mac.com/incrementalarray.html or this http://lee-mac.com/numinc.html Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 20, 2018 Share Posted June 20, 2018 My $0.05 just expanded a bit on Grrr ideas added a dialouge entry. ; simple text increment labeller ; by Alan H june 2018 (defun C:test ( / pref suff i h p s ) (if (not ah:getval3)(load "getvals3")) (ah:getval3 "Enter prefix" 5 4 "J-" "Enter start number" 5 4 "0" "Enter increment" 5 4 "1") (setq pref val1) (setq i (atoi val2)) (setq inc (atoi val3)) (setq h (getvar 'textsize)) (while (setq p (getpoint "pick point enter for done")) (setq s (strcat pref (rtos (setq i (+ inc i)) 2 0) )) (entmakex (list '(0 . "TEXT") (cons 10 p) (cons 40 h) (cons 1 s))) ) (princ "\n") ) GETVALS3.lsp Quote Link to comment Share on other sites More sharing options...
lucky9 Posted June 20, 2018 Author Share Posted June 20, 2018 Thank you asos2000 for the link Many thanks to Grrr and BIGAL , your solutions worth a million to me .. 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.