Modification of Automatically Label Attributes LEE MAC code (numbers to letters)

Modification of Automatically Label Attributes LEE MAC code (numbers to letters)

amirbSPDJQ
Contributor Contributor
455 Views
5 Replies
Message 1 of 6

Modification of Automatically Label Attributes LEE MAC code (numbers to letters)

amirbSPDJQ
Contributor
Contributor

Hello, can anyone help me to modify the Automatically Label Attributes LEE MAC code. 

At the moment the code works selecting a specific block and count the repetitions and write the number in an specific attribute tag. and one can specify a prefix or sufix.

I want the code to do the same exact thing but instead of going from 1,2,3,4... i want it to go A,B,C,D,E.... . being able to put the prefix.

 

Thank you in advance!

0 Likes
Accepted solutions (1)
456 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

The source himself may step in for you, but in the meantime:

 

Using letters in a series like that always raises this question:  What should happen if you continue beyond the length of the alphabet?  After Z [I'm assuming you're talking about the English alphabet, which is another question], should it go to AA, BB, CC etc., or A1, B1, C1 etc., or something else?

 

And for me, it raises another that you may not care about:  Should the letters I and O be left out of the series, as being too easily confused with 1 and 0 [zero]?

Kent Cooper, AIA
0 Likes
Message 3 of 6

amirbSPDJQ
Contributor
Contributor
I am working on something were i am not going to reach the last alphabet letter, so it doesnt matter, or just in case, it can be made AA AB ...
It doesnt matter if the I and O are in the count,
Thanks!!
0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

Quickie suggestion based on quickie review of the routine -- try making these changes [untested]:

 

Change this line near the top:

  autolabel:start ;; Starting number

to this:

  autolabel:start 65 ;; Starting number [65 is the ASCII character code for "A"]

and change this:

  autolabel:length ;; Fixed length numbering (set to zero if not required)

to this:

  autolabel:length ;; Fixed length numbering (set to zero if not required)

and change all instances of:
  (itoa num)

to

  (chr num)

to use the letter equivalent of that ASCII character number, rather than the text equivalent of the number itself.

 

That does not deal with the continuation past Z, but I hope will work that far.  That could probably be incorporated if needed [possibly by others even if you don't need it].  The option to pad with leading zeros could be eliminated, but can just be ignored instead.  Do all the other setting options as you need in accordance with the routine's instructions.

Kent Cooper, AIA
0 Likes
Message 5 of 6

amirbSPDJQ
Contributor
Contributor
thank you so much! it worked as wanted!!
0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

For letters past a-z then AA AB etc use Gilles defun inside getexcel.lsp uses a number. Opposite is there also.

 

 

 

 

;-------------------------------------------------------------------------------
; Number2Alpha - Converts Number into Alpha string
; Function By: Gilles Chanteau from Marseille, France
; Arguments: 1
;   Num# = Number to convert
; Syntax example: (Number2Alpha 731) = "ABC"
;-------------------------------------------------------------------------------
(defun Number2Alpha (Num# / Val#)
  (if (< Num# 27)
    (chr (+ 64 Num#))
    (if (= 0 (setq Val# (rem Num# 26)))
      (strcat (Number2Alpha (1- (/ Num# 26))) "Z")
      (strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#)))
    );if
  );if
);defun Number2Alpha

 

 

 

(number2alpha 1) = "A"

(number2alpha 26) = "Z"
(number2alpha 27) ="AA"

0 Likes