(princ "+++ 曲线或圆弧到多线段 - Chris.
[email protected] 2012-1-3 +++\n")
(princ "+++++ 输入命令\"ee\"进行操作 +++++\n")
(defun c:ee () ;任意曲线变多段线一般只用于椭圆、圆弧和样条曲线
(VL-LOAD-COM)(setvar "cmdecho" 0)
(setq ss (ssget '((0 . "ARC,*LINE,ELLIPSE"))))
(princ "\n")
(setq jj (getint "设置间距(1):"))
(if (= jj nil) (setq jj 1))
(setq lenss (sslength ss)
i 0 eelist '()
)
(repeat lenss;外循环开始
(setq en (ssname ss i);取得图元名
obj (vlax-ename->vla-object en);转换为vla对象
)
(setq ;zc (vlax-curve-getendparam obj)
j 1 );求得图元周长
(setq zc(vlax-curve-getDistAtPoint obj (vlax-curve-getEndPoint obj)))
;(setq j (- zc (* (fix(/ zc jj)) jj)));取第一段长度
(setq lst1(vlax-curve-getPointAtDist obj 0));取开始点
(repeat (fix (/ zc jj));循环周长取整次刚好到端点
;(setq ePt (vlax-safearray->list (vlax-variant-value (vla-get-coordinate obj j))))
(setq lst (vlax-curve-getPointAtDist obj j);取距开始点为j的点
; lstlen (vlax-curve-getDistAtPoint obj lst);测量开始点到j点的距离
)
(setq eelist (append eelist (list lst)));加入到点集
(setq j (+ jj j));递增jj
);内循环结束
;(setq eelist(reverse eelist))
(setq eelist (append eelist (list (vlax-curve-getEndPoint obj))))
(command ".pline" "non" lst1);开始描点
(foreach n eelist (command "non" n)(grdraw lst1 n 1) (setq lst1 n));模拟描红
(COMMAND "");描点结束
(setq eelist '());清空点集
(setq i (1+ i));下一个图元
);外循环结束
(princ "\n转换结束.")
)