试试这个快速模式:
- ;; Text Increment - Lee Mac
- ;; Increments numerical data found in a selection of Text or MText
- ;; objects by a value specified by the user.
- (defun c:txtinc ( / e i l s x )
- (if (null *inc*)
- (setq *inc* 1.0)
- )
- (if (setq i (getreal (strcat "\nSpecify Increment <" (rtos *inc* 2) ">: ")))
- (setq *inc* i)
- )
- (if (equal 0.0 (rem *inc* 1) 1e-8)
- (setq *inc* (fix *inc*))
- )
- (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "*#*"))))
- (repeat (setq i (sslength s))
- (setq e (entget (ssname s (setq i (1- i))))
- x (assoc 1 e)
- )
- (entmod
- (subst
- (cons 1
- (apply 'strcat
- (mapcar
- (function
- (lambda ( x )
- (if (and (= 'int (type x)) (= 'int (type *inc*)))
- (itoa (+ x *inc*))
- (if (member (type x) '(int real))
- (rtos (+ x *inc*) 2)
- x
- )
- )
- )
- )
- (LM:splitstring (cdr x))
- )
- )
- )
- x e
- )
- )
- )
- )
- (princ)
- )
- ;; Split String - Lee Mac
- ;; Splits a string into a list of text and numbers
- (defun LM:splitstring ( s )
- (
- (lambda ( l )
- (read
- (strcat "("
- (vl-list->string
- (apply 'append
- (mapcar
- (function
- (lambda ( a b c )
- (cond
- ( (= 92 b)
- (list 32 34 92 b 34 32)
- )
- ( (or (< 47 b 58)
- (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
- (and (= 46 b) (< 47 a 58) (< 47 c 58))
- )
- (list b)
- )
- ( (list 32 34 b 34 32))
- )
- )
- )
- (cons nil l) l (append (cdr l) (list nil))
- )
- )
- )
- ")"
- )
- )
- )
- (vl-string->list s)
- )
- )
- (princ)
|