(defun c:n()
(setq tleng 0)
(setq S (ssget '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))))
(setq n (sslength s))
(setq index (- n 1))
(repeat n (vl-load-com)
(setq ent (ssname s index))
(setq index (- index 1))
(setq curve-obj (vlax-ename->vla-object ent))
(setq leng (vlax-curve-getDistAtParam curve-obj (vlax-curve-getEndParam curve-obj) ) )
(setq tleng (+ tleng leng)) (princ leng) (princ "\n") )
(setq prscreemtext (strcat "\n总共计算" (itoa n) "个对象,总长度: " (rtos tleng 2 5)))
(princ prscreemtext) (princ) )
(defun s1712061 (&ss1 &ss2 / &a0 &dis1 &ss1 &ss2 &ss3 ff tr1 x y);写入长度到表格
(setq tr1 (strcat "D://" (rtos (* 1000000 (getvar "cdate")) 2 0) ".csv"))
(setq ff (open tr1 "w"));D盘表格Point
(while (setq &a0 (car &ss1))
(setq &ss1 (cdr &ss1))
(if (setq &ss3 (mapcar 'cdr (vl-remove-if-not '(lambda (X) (= &a0 (car x))) &ss2)))
(progn
(setq &ss3 (vl-sort &ss3 '(lambda (x y) (< x y))));长度从小到大
(while (setq &dis1 (car &ss3))
(setq &ss3 (cdr &ss3))
(write-line (strcat &a0 "," (rtos &dis1)) ff)
);while
(write-line "" ff)
)
);if
);while
(close ff)
)
大神,这个代码载入后,输入命令,运行没有错误,但是找不到相应的文件,不知道是不是没有运行成功还是文件没有保存在D盘呢?
非常感谢。