I have a routine that I use frequently at work and would like to improve it. The problem I have with it currently is that if I mis-click it cycles to the next number and I have to exit the command and start again. Basically I'd like the command to test the object to make sure it's text before running the iteration and "change" command.
(defun c:cx() ;;Edits text objects by replacing current text with a prefix and an incremental numerical suffix (setq prefix (getstring "Prefix:")) ;; prompts the user for the string prefix (setq startint (getint "Initial number:")) ;; prompts the user for the initial number (setq cnt 0) ;; intializes the counter (while (PROGN (setq ent (entsel)) ;;requests the first text to edit (setq newstring (strcat prefix (itoa (+ startint cnt)))) ;;created the string (command "change" (car ent) "" "" "" "" "" "" newstring) ;;replace the string (setq cnt (1+ cnt)) ;; increment the counter ) ) )