像这样的?
- (defun c:Test (/ s i e f o x y l lst)
- ;; Tharwat 18. mar. 2014 ;;
- (princ "\n Select texts to export to txt file :")
- (if (setq s (ssget '((0 . "TEXT") (1 . "#*"))))
- (progn (setq o (open (setq f (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".txt")) "w"))
- (write-line (strcat "DESCRIPTION" "\t" "QTY") o)
- (repeat (setq i (sslength s))
- (setq e (entget (ssname s (setq i (1- i))))
- x (cdr (assoc 1 e))
- b ""
- )
- (while (wcmatch (setq a (substr x 1 1)) "1,2,3,4,5,6,7,8,9,0")
- (setq b (strcat b a)
- x (substr x 2)
- )
- )
- (if (setq y (assoc (setq x (substr x 2)) l))
- (setq l (subst (cons x (+ (atof b) (cdr y))) y l))
- (setq l (cons (cons x (atof b)) l))
- )
- )
- (foreach x l (write-line (strcat (car x) "\t" (rtos (cdr x) 2 1)) o))
- (close o)
- (startapp "notepad.exe" f)
- )
- )
- (princ)
- )
|