(defun c:xcc (/ ) (setq i 1) (setvar "cmdecho" 0) (if (setq ee (entsel "\n选择数字 <退出>: ")) (progn (setq str (cdr (assoc 1 (entget (car ee)))) ;;返回所选文字 pt1 (cadr ee) ;;返回选择点,作为copy的第一点 strs (substr str 1 (aa str)) ;;截取非数字字符 strn (substr str (+ (aa str) 1) (strlen str))) ;;截取数字字符 (command "copy" ee "" "m" pt1 (while (progn (setq news (strcat strs (itoa (+ (atoi strn) i)))) (setq i (+ 1 i) pt1 pt2) (command pause) ;;暂停等待屏幕输入 (setq pt2 (getvar "LASTPOINT")) ;;获取输入点 (setq e (entlast)) (entmod (subst (cons 1 news)(assoc 1 (entget e))(entget e))) (princ news)(princ "\n选择数字 <退出>: ") (not (eq pt1 pt2)) ))) ) ) (princ) ) ;;返回数字在字符中的位置 (defun aa(tr / n i m k) (setq n (strlen tr) i 0 k -1) (while (< i n) (setq m (substr tr (- n i) 1)) (if (/= (itoa (atoi m)) m) (setq k i i n)) (setq i (+ i 1))) (- (strlen tr) (if (= k -1) i k)) ) |