Message 1 of 7

Not applicable
03-16-2021
04:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi I'm sure this has been posted a million times before (I've checked but no luck with quite what I'm looking for), so sorry in advance! I'm trying to create a command that will renumber details on a sheet for me, by first picked the text I'd like to change then telling it what number I'd like to start from. The one caveat being that I'd like to make sure anything less than 9 shows up as "01" etc. Currently getting a "lentityp nil" error when I try what I've got so far.
Thank you!
(defun c:dnum (/ index numb a n b1 str b iTx fmtval str newStr d )
(setq a ( ssget ) )
(setq n ( sslength a ) )
(setq index ( getint "\nBeginning Number: "))
(setq numb ( - index 1 ))
(repeat n
(setq b1 ( ssname a numb ) );Step through list
(setq numb ( + numb 1 ) );Increment number
(setq b ( entget b1 ) );Copy the list
(setq iTx ( assoc 1 b ) );Old Text
(setq fmtval ( rtos numb 2 0 ) );Format number
(if ( <= fmtval 9 )
(setq str (strcat "0" (itoa fmtval )))
(setq str (itoa fmtval))
)
(setq newStr ( strcat fmtval ) );combine formatted value with string
(setq d ( cons ( car iTx ) newStr ) );construct new list
(setq b1 ( subst d iTx b ) );replace old list with new list
(entmod b1 ) ;update the list
)
)
Solved! Go to Solution.