Jump to content

Test an object to see if it's text


ABuckingham

Recommended Posts

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...