Was just about to post this actually:
- (defun c:AttInc (/ MStr ss att str pos num) (vl-load-com) (setq mStr (lambda (string) (while (< (strlen string) len) (setq string (strcat "0" string))) string)) (or *start (setq *start "100")) (while (not (setq num (distof (setq *start (cond ((/= "" (setq tmp (getstring (strcat "\nSpecify Starting Number : ")))) tmp) (*start))))))) (setq len (strlen *start) num (fix num)) (princ "\nSelect Block to Increment: ") (while (setq ss (ssget "_:S" '((0 . "INSERT") (66 . 1)))) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss 0)) 'GetAttributes) (setq str (vla-get-TextString att)) (vla-put-TextString att (if (setq pos (vl-string-position 45 str)) (strcat (setq *start (mStr (itoa num))) (substr str (1+ pos))) (setq *start (mStr (itoa num)))))) (setq num (1+ num))) (princ))
Updated to correct while loop. |