为什么不一次说清楚呢??
- ;;;;输出excel
- (defun lst2csv(lsthead tipstr lst / ff1 ff2 i pro ele )
- (SETQ lst (cons lsthead lst)
- ff1 (getfiled "输出到excel" tipstr "CSV" 1)
- ff2(open ff1 "a")
- i 0
- )
- (repeat (length LST)
- (SETQ pro (nth i lst)
- ele (vl-string-translate "( )" ",,,"(vl-princ-to-string pro))
- ele (vl-string-subst "" "," ele)
- i (1+ i)
- )
- (write-line ele ff2)
- )
- (close ff2)
- )
- ;;;矩形周长面积,只对无旋转的矩形有效
- (defun c:tt(/ ss n e vlae mj zc jielst)
- (setq ss(ssget '((0 . "LWPOLYLINE"))))
- (if ss
- (progn
- (setq n 0)
- (repeat (setq n(sslength ss))
- (setq e(ssname ss (setq n(1- n)))
- vlae(vlax-ename->vla-object e)
- )
- (if (=(vla-get-closed vlae):vlax-true)
- (progn
- (setq s(entget e))
- (foreach x s
- (if (= (car x)10)(setq p10_lst(cons (cdr x) p10_lst)))
- )
- (if(equal (angle (car p10_lst)(cadr p10_lst)) 0.0 1e-3)
- (progn
- (setq xdelta(distance (car p10_lst)(cadr p10_lst)))
- (setq ydelta(distance (car p10_lst)(last p10_lst)))
- )
- (progn
- (setq ydelta(distance (car p10_lst)(cadr p10_lst)))
- (setq xdelta(distance (car p10_lst)(last p10_lst)))
- )
- )
- (setq jielst(cons (list (1+ n) xdelta ydelta) jielst))
- )
- )
- )
- )
- )
- (princ (strcat "矩形长宽列表如下:" (vl-princ-to-string jielst)))
- (setq lsthead '("序号""矩形X增量" "矩形Y增量")
- tipstr "矩形数据列表"
- )
- (lst2csv lsthead tipstr jielst)
- (princ)
- )
|