Lisp & Tips/Lisp
문자 또는 숫자 자동 증가
이자더
2014. 11. 22. 23:55
문자 또는 숫자 자동 증가
(defun c:tag ( / fun ins ocs str uxa ) (while (not (or (= "" (setq str (getstring "\nSpecify grid line tag: "))) (wcmatch str "~*[~0-9]*") (wcmatch str "~*[~a-zA-Z]*") ) ) (princ "\n 숫자 또는 알파벳문자이어야 함...") ) (if (/= "" str) (progn (if (wcmatch str "~*[~0-9]*") (setq fun (lambda ( x ) (itoa (1+ (atoi x))))) (setq fun LM:A++) ) (setq ocs (trans '(0.0 0.0 1.0) 1 0 t) uxa (angle '(0.0 0.0 0.0) (trans (getvar 'ucsxdir) 0 ocs t)) ) (while (setq ins (getpoint "\nSpecify point
;; Alpha++ - Lee Mac ;; Increments an alphabetical string by one, e.g. AZ => BA ;; a - [str] alphabetical string (defun LM:A++ ( a ) ( (lambda ( f ) (vl-list->string (reverse (f (reverse (vl-string->list a)) t)))) (lambda ( l x ) (cond ( (null l) (if x '(65) '(97))) ( (= 090 (car l)) (cons 65 (f (cdr l) t ))) ( (= 122 (car l)) (cons 97 (f (cdr l) nil))) ( (cons (1+ (car l)) (cdr l))) ) ) ) ) (princ)