AsbjornM Posted November 12, 2012 Posted November 12, 2012 Hi! I'm working on a big project. I have about 5600 units whit unique numbering/labels. Examples of labels: SQ.2.20.32 RB.2.20.04 When a add a new unit, I have to manually increase the numbering of following units by +1. Is there possible for me to make a button with a function that does this automaticly? Example: I press a label that say "SQ.2.20.32" and it changes to "SQ.2.20.33" I press a label that say "RB.2.20.04" and it changes to "RB.2.20.05" This would save me hours of boring work so I would really appreciate it if anyone could help me:) Quote
JGA Posted November 12, 2012 Posted November 12, 2012 I use a diesel macro that works from 0, but I think you would need lisp to manage such a complex numbering system. *^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1)) Quote
BIGAL Posted November 22, 2012 Posted November 22, 2012 If always 2 decs easy a start ; from help ;Substr string start length (setq ans (getstring "\type in code part num above")) (setq number ( - (strlen ans) 2)) (princ (substr ans number 2)) ; you need to do some convert to real add 1 then RTOS & strcat etc Quote
AsbjornM Posted November 22, 2012 Author Posted November 22, 2012 Thank you for helping me:) (setq ans (getstring *^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1)))) (setq number ( - (strlen ans) 2)) (princ (substr ans number 2)) I've added this code to a button, but all that happens is that when I press a label a new label that say "0" is created. ; you need to do some convert to real add 1 then RTOS & strcat etc I'm not familiar with autolisp so I guess that I need to learn much more before I get it to work:) Quote
AsbjornM Posted November 22, 2012 Author Posted November 22, 2012 (setq ans (getstring *^C^Ctext;_m;\;;$M=$(getvar,USERI1);setvar;USERI1;$(+,1,$(getvar,USERI1)))) (princ ans) Shouldn't this code prit the same as the label I click? All that happens is that when I press a label a new label that say "0" is created. Quote
BIGAL Posted November 23, 2012 Posted November 23, 2012 I would not mix diesel inside a lisp rather do everything as a lisp proceedure, using ENTSEL you can pick an object and check if its text so then do next step. (setq en1 (car (entsel "\nSelect first text number:" ))) (setq el1 (entget en1)) (if (= (cdr (assoc 0 el1)) "TEXT") (progn (setq ans (cdr (assoc 1 el1))) (setq number ( - (strlen ans) 1)) (princ (substr ans number 2)) ) ) Quote
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.