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

Incrementing pick points alphabetically

3 REPLIES 3
Reply
Message 1 of 4
smaher12
613 Views, 3 Replies

Incrementing pick points alphabetically

I know how to increment pick points numerically (see below). How is it done alphabetically?

 

(defun C:test (/ pt# pt)
   (setq pt# (getint "\nEnter number: "))
     (while
       (setq pt (getpoint "\nSpecify point: " ))
         (if (/= pt nil)
           (progn
             (command "TEXT" "M" pt "" "" pt#)
             (setq pt# (1+ pt#))
           )
         )
      )
 (princ)
)

 

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: smaher12


@smaher12 wrote:

I know how to increment pick points numerically (see below). How is it done alphabetically?

.... 


You need to use the (ascii) and (chr) functions to give integer equivalents to letters so that you can increment them upward, for example:
 

(defun C:test (/ ltr asc pt)
  (setq
    ltr (getstring "\nEnter starting letter: ")
    asc (ascii ltr)
  )
  (while
    (setq pt (getpoint "\nSpecify point: " ))
    (progn
      (command "TEXT" "M" pt "" "" (chr asc))
      (setq asc (1+ asc))
    )
  )
  (princ)
)

 

Consider whether you need to make it more sophisticated, for instance, if the User picks enough points to go past Z [or z], it will move into punctuation characters, but you could have it go into double letters instead.  I think there are threads on this Forum that include ways to do that.  You could also have it check whether the User entered a single letter, or let them start with a double letter, and some other things.

Kent Cooper, AIA
Message 3 of 4
smaher12
in reply to: Kent1Cooper

Thank you Kent. I am looking at the following post (message 4) to consider what to do after Z or z.

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Auto-Increment-Letter/td-p/2325302

 

 

Message 4 of 4
Lee_Mac
in reply to: smaher12

You may also be interested in my Increment Alpha & Alpha++ functions as part of my set of Column Reference Functions - that page also provides examples of how to call the functions with the required arguments.

 

I hope this helps!

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

Post to forums  

Autodesk Design & Make Report

”Boost