Author Topic: Number/Letter incrementation  (Read 1617 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Number/Letter incrementation
« on: February 17, 2009, 01:38:52 PM »

Hi fellas.

I need a little expert assistance.

I need this snippet of code to allow letters to be part of the number and have it self increment to the next value. I hope I explained this clearly. Thanks in advance!

Code: [Select]
(if (= start nil)
  (setq start "01001");<-----------------This is where I need to be able to have letters as well i.e. P1001 etc....
)
  (setq startc "")
  (while (not (numberp (distof startc)))
    (setq startc (getstring (strcat "\nStarting number <" start ">: ")))
    (and (= startc "") (setq startc start))
  )
  (setq minlen (strlen startc))
(setq pt curPoint)
       (command ".text" "M" pt "" startc)
(setq nspid startc)
     (setq startc (itoa (1+ (atoi startc))))
     (while (< (strlen startc) minlen) ; prepend zeros
       (setq startc (strcat "0" startc))
     )
  (setq start startc)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Number/Letter incrementation
« Reply #1 on: February 17, 2009, 01:52:43 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Number/Letter incrementation
« Reply #2 on: February 17, 2009, 02:20:47 PM »

Great, I will check that out. Thanks Ronjonp
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Number/Letter incrementation
« Reply #3 on: February 17, 2009, 02:28:22 PM »
Here is the most recent version.
http://www.theswamp.org/index.php?topic=27291.msg330240#msg330240

I will update the thread as soon as I finish the cleanup of this routine.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.