ABuckingham Posted October 2, 2008 Share Posted October 2, 2008 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 ) ) ) Thoughts? Quote Link to comment Share on other sites More sharing options...
borgunit Posted October 3, 2008 Share Posted October 3, 2008 Probably would want to replace entsel with something like this (ssget '((0 . "TEXT"))) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.