按剩余量、能切个数、材料规格排了出来,按剩余量大小排列顺序,剩余量是所剩材料的面积(没记厚度,不同厚度应该不能使用吧)至于用哪个,你自己选吧- (defun An_Sta(sta / i strtmp data ch)
- (setq i 1)
- (setq strtmp "" data "")
- (repeat (strlen sta)
- (setq ch (substr sta i 1))
- (if (or (= ch "-") (= ch "x"))
- (progn
- (setq data (strcat data strtmp " "))
- (setq strtmp "")
- )
- (setq strtmp (strcat strtmp ch))
- )
- (setq i (1+ i))
- )
- (setq data (strcat data strtmp))
- (read (strcat "(" data ")"))
- )
- (defun c:mat( / lib sta seldata res)
- (setq lib '("-2100x20x9000" "-2200x20x8500" "-2300x20x7000" "-2250x20x8700"))
- (setq s 2);切割系数
- (while (not (wcmatch (setq sta (getstring "输入规格:")) "*x*")))
- (setq lib (mapcar 'an_sta lib))
- (setq sta (an_sta sta))
- (setq seldata (mapcar '(lambda(e) (if (and (= (cadr e) (cadr sta)) (>= (last e) (last sta))) e nil)) lib))
- (if (setq seldata (vl-remove nil seldata))
- (progn
- (setq res (mapcar '(lambda(e / re1 re2 n)
- (setq re1 (- (car e) (* (setq n (fix (/ (car e) (+ s (car sta))))) (+ s (car sta)))))
- (setq re2 (- (last e) (* (fix (/ (last e) (+ s (last sta)))) (+ s (last sta)))))
- (list (* re1 re2) n (strcat "-" (rtos (car e)) "x" (rtos (cadr e)) "x" (rtos (caddr e))))
- )
- seldata)
- )
- (setq res (vl-sort res '(lambda(e1 e2) (< (car e1) (car e2)))))
- (prin1 res)
- )
- (princ "没有符合要求的材料规格!")
- )
- (princ)
- )
|