- 积分
- 838
- 明经币
- 个
- 注册时间
- 2018-3-11
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2019-1-22 18:53:33
|
显示全部楼层
这是选线计算加工价格,其中红线有错误,水平有限没找到原因,望改正。
(vl-load-com)
(defun C:999 (/)
(setq LST '(("LINE" "直线")
("ARC" "圆弧")
("CIRCLE" "圆")
("LWPOLYLINE" "多段线")
("ELLIPSE" "椭圆")
("SPLINE" "样条线")
)
)
(if (setq SS (ssget '((0 . "LINE,ARC,CIRCLE,LWPOLYLINE,ELLIPSE,SPLINE"))
)
)
(progn
;;1.逐个统计
(setq I 0)
(repeat (sslength SS)
(setq EN (ssname SS I)
ENT (entget EN)
STR (cdr (assoc 0 ENT))
)
(if (setq TMP (assoc STR LST))
(setq LEN (vlax-curve-getdistatparam
EN
(vlax-curve-getendparam EN)
)
LST (subst (append TMP (list LEN)) TMP LST)
)
)
(setq I (1+ I))
)
;;2.显示
(setq PRTXT
"线条长度分类统计\n\n类型\t根数\t长度\n----------------------"
)
(foreach N LST
(if (> (length N) 2)
(setq LEN (apply '+ (cddr N))
PRTXT (strcat PRTXT
"\n"
(cadr N)
"\t"
(itoa (- (length N) 2))
"\t"
(rtos LEN 2 3)
)
)
)
)
(setq LL (apply '+ (apply 'append (mapcar 'cddr LST))) )
(setq HD (getreal "\n请输入零件高度<30>:"))
(setq JJ (* ll(* HD(* 0.0043))) ) ;;; 修改这一行
(setq PRTXT (strcat PRTXT "\n\n总数:" (itoa (- (length (apply 'append LST)) (* 2 (length LST))))
" 总长度:" (rtos LL 2 2)
" 总价格:" (rtos JJ 2 2) ;;; 修改这一行
)
)
(princ PRTXT)
(alert PRTXT)
)
)
(princ)
) |
|