sgyyuan 发表于 2013-3-22 16:09
感谢 ll_j,我对LISP是小白,只是应用需要,从坛里找的,挺好用,就差顺序,如果您没时间细弄,能否请您帮我 ...
- (defun c:Q (/ SS FF I ent e1 ey sel)
- (if (and (setq SS (ssget '((0 . "*TEXT"))))
- (if (findfile "d:\\ABC.csv")
- (setq FF (open "d:\\ABC.csv" "a"))
- (setq FF (open "d:\\ABC.csv" "w"))
- )
- )
- (progn
- (setq I -1
- sel nil
- )
- (repeat (sslength SS)
- (setq i (1+ i)
- ent (entget (ssname ss i))
- e1 (cdr (assoc 1 ent))
- ey (caddr (assoc 10 ent))
- sel (cons (list e1 ey) sel)
- )
- )
- (setq sel (vl-sort sel '(lambda (y1 y2) (> (cadr y1) (cadr y2)))))
- (mapcar '(lambda (e)
- (princ e FF)
- (princ "\n" ff)
- )
- (mapcar 'car sel)
- )
- (close ff)
- )
- )
- (princ)
- )
|