- (defun c:tt(/ e e1 e2 f n m p pp p0 pt y x r r0)
- (setq f (open "D:/test.txt" "w"))
- (setq s (ssget))
- (setq n (sslength s) m 0 pp '())
- (repeat n
- (setq e (ssname s m) m (1+ m))
- (setq e1 (entget e))
- (setq e2 (cdr(assoc 0 e1)))
- (if (= e2 "CIRCLE")
- (progn
- (setq pt (cdr (assoc 10 e1)))
- (setq y (car pt) x (cadr pt))
- (setq r (cdr (assoc 40 e1)))
- (setq pp (cons (list r y x) pp))
- )
- )
- )
- (setq pp (sort_pList pp))
- (setq m 0 r0 nil)
- (repeat (length pp)
- (setq p (nth m pp) m (1+ m))
- (setq r (car p))
- (setq p0 (strcat "N" (rtos m 2 0) "," (rtos (cadr p) 2 2) "," (rtos (caddr p) 2 2)))
- (if (/= r r0)
- (progn
- (write-line (strcat "D" (rtos r 2 2)) f)
- (write-line p0 f)
- (setq r0 r)
- )
- (progn
- (write-line p0 f)
- )
- )
- )
- (close f)
- (princ)
- )
- ;;;对点表按xyz排序
- (defun sort_pList (plist / fp pt)
- (setq plist (vl-sort plist
- '(lambda (p1 p2)
- (cond ((< (car p1) (car p2)) T)
- ((and (= (car p1) (car p2))
- (> (caddr p1) (caddr p2))
- )
- T
- )
- ((and (= (car p1) (car p2))
- (= (caddr p1) (caddr p2))
- (< (cadr p1) (cadr p2))
- )
- T
- )
- (T nil)
- )
- )
- )
- )
- )
|