导出线段的长度到excel
(defun c:tee ( / &a0 &dis1 &k1 &kw1 &ss1 &ss2)(if (null vlax-dump-object) (vl-load-com) )
(princ "\n请选择曲线")
(setq &ss1 '("LINE" "LWPOLYLINE" "CIRCLE" "ARC" "HELIX" "ELLIPSE" "SPLINE" "POLYLINE"))
(if (setq &kw1 (ssget '((0 . "LINE,LWPOLYLINE,CIRCLE,ARC,HELIX,ELLIPSE,SPLINE,POLYLINE"))))
(progn
(setq &ss2 '())
(while (setq &k1 (ssname &kw1 0))
(setq &kw1 (ssdel &k1 &kw1) &a0 (cdr (assoc 0 (entget &k1))))
(setq &dis1 (vlax-curve-getDistAtParam &k1 (vlax-curve-getEndParam &k1)))
(setq &ss2 (cons (cons &a0 &dis1) &ss2))
);while
(s1712061 &ss1 &ss2)
)
)
(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"))
(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
(while (setq &dis1 (car &ss3))
(setq &ss3 (cdr &ss3))
(write-line (strcat &a0 "," (rtos &dis1)) ff)
);while
(write-line "" ff)
)
);if
);while
(close ff)
)
试了没用啊。。。 谢谢分享!
测试了一下
可以使用 CSV这个格式好。 多谢楼主分享 感谢大佬分享 测试ok,对于电线电缆计算很直观,也能利用excel的特性加总、加乘,方便很多,感谢大佬分享。
页:
[1]