Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Auto increment letters

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
psilzle1968
2208 Views, 10 Replies

Auto increment letters

I am looking for a LISP routine that would do the following.  I just want to be able to always start with the letter A in a drawing and continue through Z and then go to AA, AB, AC......  BA, BB, BC, etc.   I also need a box drawn around the letters at the insertion point.  I do not need it to prompt me for the letters if it is able to.  I just want to pick and have it place A with a box, next pick is B with a box, etc.  If I were to break out of the routine to do something I would like it to start where I left off.  Thoughts?  I have a routine that does this for numbers with a circle around it, but I am not good enough at LISP to figure out this version.  Any help would be appriciated.

 

Paul Silzle

10 REPLIES 10
Message 2 of 11
rkmcswain
in reply to: psilzle1968

Take a look at this:

http://lee-mac.com/numinc.html

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 11

Something like this

(defun mod (a b)
  (- a (* (/ a b) b)))

(defun letter (i)
  (chr (+ i 64)))

(defun letters (i / head tail)
  ;; 0 -> "A", 25 -> "Z", 26 -> "AA"
  (setq head (/ i 26)
        tail (mod i 26))
  (if (zerop head)
      (letter i)
      (strcat (letters (1- head)) (letter tail))))

 

for generating the text to insert

 

-- 

 

Message 4 of 11
psilzle1968
in reply to: rkmcswain

The lisp routine in that link is perfect!!!  That is exactly what we needed!!  Thank you very much!!!

Message 5 of 11
Lee_Mac
in reply to: psilzle1968

Thank you for the recommendation @Anonymous , much appreciated!

 

I'm glad you found the program useful @psilzle1968! Smiley Happy

 

@martti.halminen why not use the rem function?

Message 6 of 11
martti.halminen
in reply to: Lee_Mac


@Lee_Mac wrote:

 

@martti.halminen why not use the rem function?


Just forgot it existed; been lately reading Delphi code where the near equivalent is Mod.

 

--

Message 7 of 11
rkmcswain
in reply to: Lee_Mac

Lee_Mac wrote:

Thank you for the recommendation @*R.K. McSwain , much appreciated!

The credit really goes to @rkmcswain  - that other guy is never on here.... 😉

 

R.K. McSwain     | CADpanacea | on twitter
Message 8 of 11
Lee_Mac
in reply to: rkmcswain

rkmcswain wrote:
Lee_Mac wrote:

Thank you for the recommendation @*R.K. McSwain , much appreciated!

The credit really goes to @rkmcswain  - that other guy is never on here.... 😉

 

Oops! That was the name which popped up automatically as I wrote the message Smiley Embarassed

Message 9 of 11
3wood
in reply to: psilzle1968

You can try attached INNB.vlx.

It doesn't add "A" as prefix automatically after letter "Z", but you can define it manually.

You can either draw a shape around the first letter and select the letter and the shape, or define a block with attribute.

Message 10 of 11
rkmcswain
in reply to: Lee_Mac

Lee_Mac wrote:

Oops! That was the name which popped up automatically as I wrote the message Smiley Embarassed

Ha. It's not our fault. I've got several other accounts floating around out there. Not because I created them, but I think it's a side effect of the NNTP to HTTP migration and other account migrations/adjustments that Autodesk has done over the years. I wish they would consolidate these into my current account. I'd gain 10,000 posts 🙂

 

10500.png

R.K. McSwain     | CADpanacea | on twitter
Tags (2)
Message 11 of 11
Lee_Mac
in reply to: rkmcswain

Wow - you've been busy over the years RK Smiley Wink

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost