- (defun c:tt (/ SAVEFILE SS F N E PL MINPT MAXPT WH S DATA cmdecho)
- (setq cmdecho (getvar 'cmdecho))
- (setvar 'cmdecho 0)
- (if (and
- (setq savefile (getfiled "" "" "csv" 1))
- (setq ss (ssget '((0 . "lwpolyline")
- (-4 . "<or")
- (70 . 129)
- (70 . 1)
- (-4 . "or>")
- (90 . 4)
- )
- )
- )
- )
- (progn
- (setq f (open savefile "a"))
- (WRITE-LINE "编号,宽度,高度" f)
- (repeat (setq n (sslength ss))
- (setq e (ssname ss (setq n (1- n))))
- (setq pl (mapcar 'cdr
- (vl-remove-if-not
- '(lambda (x) (= 10 (car x)))
- (entget e)
- )
- )
- )
- (setq minpt (apply 'mapcar (cons 'min pl))
- maxpt (apply 'mapcar (cons 'max pl))
- )
- (setq wh (list (distance (car pl) (cadr pl))
- (distance (caddr pl) (cadr pl))
- )
- )
- (command "zoom" "w" minpt maxpt "zoom" ".95x")
- (setq s (ssget "wp" pl '((0 . "*text"))))
- (if s
- (setq data (cons (list (cdr (assoc 1 (entget (ssname s 0))))
- (rtos (apply 'max wh) 2 2)
- (rtos (apply 'min wh) 2 2)
- )
- data
- )
- )
- )
- )
- (setq data (vl-sort data '(lambda (a b) (< (car a) (car b)))))
- (foreach a data
- (WRITE-LINE (strcat (car a) "," (cadr a) "," (caddr a)) f)
- )
- (close f)
- )
- )
- (setvar 'cmdecho cmdecho)
- (princ)
- )
|