Could you please have a look on my thread:
Is there a way to give the existence text a “serial letters”?
"Serial numbers"
What is it?
Show us an example, say
like this:
A-1
A-1
A-3
I don't understand
I use this for alphanumeric
(defun inc_txt (Txt / Boucle Decalage Val_Txt) (setq Boucle 1 Val_txt "") (while (<= Boucle (strlen Txt)) (setq Ascii_Txt (vl-string-elt Txt (- (strlen Txt) Boucle))) (if (not Decalage) (setq Ascii_Txt (1+ Ascii_Txt)) ) (if (or (= Ascii_Txt 58) (= Ascii_Txt 91) (= Ascii_Txt 123)) (setq Ascii_Txt (cond ((= Ascii_Txt 58) 48) ((= Ascii_Txt 91) 65) ((= Ascii_Txt 123) 97) ) Decalage nil ) (setq Decalage T) ) (setq Val_Txt (strcat (chr Ascii_Txt) Val_Txt)) (setq Boucle (1+ Boucle)) ) (if (not Decalage) (setq Val_Txt (strcat (cond ((< Ascii_Txt 58) "0") ((< Ascii_Txt 91) "A") ((< Ascii_Txt 123) "a") ) Val_Txt ) ) ) Val_Txt )
Exemple:
(inc_txt "A") "B"
(inc_txt "Z") "AA"
(inc_txt "09") "10"
(inc_txt "9") "00"
(inc_txt "Z9") "AA0"
(inc_txt "AZ9") "BA0"
(inc_txt "a1z8") "a1z9"
(inc_txt "a1z9") "a2a0"
etc...
Joint complete routine for insert a block with incremented attribut
Thank you CADaStroumph.
The lsp code that you have provided seems not to work.
Is there something missing in the code? i comapred it with another lsp file to see what might be missing.
What might be the problem?
Best
Jamal
Thanks Hallex,
For example, in the first screenshot below, I wanted to automatically switch the “A” texts to be as in the screenshot 2
We can do the same thing if we have numbers using the “auto number” command (screenshot 4 and 5)
Best
Jamal
Give this a shot
{code}
;; fixo () 2012 * all rights released ;; 3/5/12 ;; renumbering selected texts (defun C:REAN(/ alist en enlst ent got) ;;local function based on code by Tom Brabant (tom.brabant) (defun inc-str (string) (cond ((= "Z" string) "AA") ((= 1 (strlen string)) (chr (1+ (ascii string)))) ((= 2 (strlen string)) (strcat (substr string 1 1) (chr (1+ (ascii (substr string 2 1))))) ) (t (princ "\nwarning: unhandled string passed to function inc-str") (princ) nil) ) ) ;; main part ;; (command "_undo" "_begin") (while (setq ent (entsel "\nSelect text or Enter to Exit: ")) (setq en (car ent)) (redraw en 3) (setq enlst (cons en enlst))) (setq enlst (reverse enlst)) (setq *st* (cdr (assoc 1 (entget (car enlst))))) (if (vl-string-position (ascii *st*) "0123456789") (progn(setq got T)(setq *st* (itoa (1- (atoi *st*))))) (progn(setq got nil)(setq *st* (chr (1- (ascii *st*))))) ) (foreach en enlst (setq alist (entget en)) (setq alist (subst (cons 1 (if got (setq *st* (itoa (1+ (atoi *st*)))) (setq *st* (inc-str *st*))) ) (assoc 1 alist) alist) ) (entmod alist) (entupd en) ) (redraw) (command "_undo" "_end") (princ) ) (princ "\nType REAN to execute...") (princ)
{code}
~'J'~
Why i don't see the "/" (slash) in your notepad ?
The fonction inc_str required an argument; arg:Txt (must be a string) and local variable: Boucle Decalage Val_Txt
Your image:
(defun inc_txt (Txt Boucle Decalage Val_Txt)
My code:
(defun inc_txt (Txt / Boucle Decalage Val_Txt)
Many thanks Hallex. This code is working very well.
Could this be developed to allow the window selection instead of selecting the letters one by one exactly the same way “auto number” command is working?
Best
Jamal
Thanks CADaStroumph.
still the code is not working. please, have a look on the screenshot below?
best
jamal
I think you need to read more about the syntax of the (defun) function.
When it's used like this:
(defun C:MarilynMonroe (/ mickey mouse)
with the C: at the beginning, and with nothing between the ( and the /, then what is defined is a COMMAND [that's what the C stands for], and can be used by typing simply the Command name:
MarilynMonroe
or, if called from inside another Lisp function, with both the C: and surrounding parentheses:
(C:MarilynMonroe)
It's not allowed to have anything [other than spaces if you want them] between the ( and the /, that is, it's not allowed to have "arguments". The mickey and mouse are localized variables that will be used within the operation of the Command; such definitions do not always include localized variables, and if they don't, they can have the () without the / inside, but they still must have the ().
When it's used like this:
(defun OrsonWelles (gold silver bronze / up down sideways)
without the C: at the beginning, and with or without arguments listed between the ( and the /, then what is defined is a [people use different words] FUNCTION or ROUTINE or SUB-ROUTINE. It is allowed to have arguments [the gold and silver and bronze], though it is not required to. [It may or may not also have localized variables after the /, and if it has no arguments or localized variables, it still must have the (), with or without a / inside.] Such a function must be used with parentheses around the function name, and if any arguments are listed, values for all of them must also be supplied inside the parentheses:
(OrsonWelles 12.5 "hello" T)
Your
(defun C:inc_txt (Txt / Boucle .....
is a violation of the distinction between Command and Function definitions. If it has the C:, it may not have the Txt argument before the /; if it has the Txt argument, it may not have the C:.
Try edited version attached
~'J'~
Perfect Hallex. You are a star.
this is what i've been looking for long time ago.
that's really brilliant.
many thanks
Jamal
Sorry Hallex.
sounds the the lisp file doesn't work properly. please, have a look on the screeshot below
what might cause this error?
best
Jamal
Many thanks Kent for the elaboration. appreciated.
best
Jamal
Hi Hallex,
I'm not sure if your time permits to develop the code a bit more to be the same the way the "Automatic Text Numbering" works with all its options.
Why the message "impossible to sort selected texts" is generated?
Many thanks
best
Jamal
Hi Jamal
You wrote:
>> Why the message "impossible to sort selected texts" is generated?
All text must have equal X or Y coordinates you can ssee it within sort function
Try to change fuzz factor instead of 0.001 set to 0.1 for example
best
~'J'~