这
- (defun c:Test (/ v lst n s ss)
- ;;------------------------------------;;
- ;; Tharwat 03.06.2015 ;;
- ;; Increment with a number entered ;;
- ;; by a user if the tag string is ID ;;
- ;;------------------------------------;;
- (if
- (and (setq v (getstring
- "\nSpecify String with integer number at the end :"
- )
- )
- (if (setq lst (_parseInt v))
- (setq n (read (car lst))
- s (cadr lst)
- )
- (progn
- (alert
- "\nEntered value must have integer number at the end !"
- )
- nil
- )
- )
- (princ "\nSelect Attributed Block that have ID tag name :")
- (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
- )
- ((lambda (i / sn)
- (while (setq sn (ssname ss (setq i (1+ i))))
- (mapcar
- '(lambda (a)
- (if (eq (strcase (vla-get-tagstring a)) "ID")
- (progn
- (vla-put-textstring
- a
- (strcat s
- (if (< n 10)
- (strcat "0" (itoa n))
- (itoa n)
- )
- )
- )
- (setq n (1+ n))
- )
- )
- )
- (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
- )
- )
- )
- -1
- )
- )
- (princ)
- )(vl-load-com)
- (defun _parseInt (v / l)
- (setq v (vl-list->string (reverse (vl-string->list v))))
- (while (and v (numberp (read (setq n (substr v 1 1)))))
- (setq l (cons n l)
- v (substr v 2)
- )
- )
- (if l
- (list (apply 'strcat l)
- (vl-list->string (reverse (vl-string->list v)))
- )
- )
- )
|