Convert sequential numbering to sequential lettering in this lisp

Convert sequential numbering to sequential lettering in this lisp

annoisscary
Advocate Advocate
282 Views
2 Replies
Message 1 of 3

Convert sequential numbering to sequential lettering in this lisp

annoisscary
Advocate
Advocate

As the title states I need to convert this to lettering *if* possible.

 

(defun c:BDX (/ ss s1 n1 N2 fld1) 
	(defun *error* (msg)
	(setvar "filedia" fld1)
	(and msg(not (wcmatch (strcase msg)"*CANCEL*,*QUIT*,*BREAK*,*EXIT*"))
	    (princ (strcat "\nError: " msg))
	)
	(setvar "cmdecho" 1)

    (princ)
)
  (princ "select object")
  (setq ss (ssget ":S")
        S1 (getstring "\nEnter Prefix: ")
        n1 (getint "\nEnter Suffix: ")
  )
  (setq fld1 1)
  (setvar "filedia" 0)
  (while ss 
    (SETQ N2 (ITOA N1))
    (setvar "cmdecho" 0)
    (command "_.dxfout" (strcat "u:/v/batch-dxf/" S1 N2 ".dxf") "e" ss "" "v" "2013" "16")
    (princ "select object")
    (setq ss (ssget ":S") ;if
          n1 (+ n1 1)
    )
  ) ;_ end of while
  (setvar "filedia" 1)
  (princ)
) ;_ end of defun
0 Likes
Accepted solutions (1)
283 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Use can use this... I guess it's made for the capitals.

 

  (defun inc-str (string)
    (cond ((= "Z" string)          "AA")
	  ((wcmatch string "@Z")   (strcat (chr (1+ (ascii (substr string 1 1)))) "A"))
	  ((wcmatch string "@ZZ")  (strcat (chr (1+ (ascii (substr string 1 1)))) "AA"))
	  ((= 1 (strlen string))   (chr (1+ (ascii string))))
	  ((= 2 (strlen string))   (strcat (substr string 1 1) (chr (1+ (ascii (substr string 2 1))))))
	  ((princ "\nwarning: unhandled string passed to function inc-str") nil)))

 

0 Likes
Message 3 of 3

annoisscary
Advocate
Advocate

Thanks for the function, Took a little playing around but I've got it implemented and fully functional.

0 Likes