 - ;;;数学求解
- (defun delta(b c / x1 x2 x3 x4 dta)
- (cond
- ((>(setq dta(-(expt b 2)(* 4 c)))0);;;长方形
- (setq x1 (/(+ b(sqrt dta))2)
- x2 (/(- b(sqrt dta))2)
- )
- (if (>= x1 x2)(setq x3 x1 x4 x2)(setq x3 x2 x4 x1))
- )
- ((equal(setq dta(-(expt b 2)(* 4 c)))0 1e-3);;;正方形
- (setq x1 (/ b 2)
- x3 x1
- x4 x1
- )
- )
- ((<(setq dta(-(expt b 2)(* 4 c)))0);;;数学嘛
- (alert"\n无解")
- )
- )
- (if (and x3 x4)(setq jie(list x3 x4)))
- )
- ;;;;输出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)
- )
- ;;;矩形周长面积,输出excel请自理
- (defun c:getzcmj(/ ss n e vlae mj zc jie jielst)
- (setq ss(ssget '((0 . "LWPOLYLINE"))))
- (if ss
- (progn
- (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 mj(vla-get-area vlae)
- zc(vla-get-length vlae)
- )
- (delta (/ zc 2) mj)
- (if jie (setq jielst(cons jie jielst)))
- )
- )
- )
- )
- )
- (princ (strcat "矩形长宽列表如下:" (vl-princ-to-string jielst)))
- (setq lsthead '("矩形长度" "宽度")
- tipstr "矩形长宽列表"
- )
- (lst2csv lsthead tipstr jielst)
- (princ)
- )
|