看下这个: (defun c:ee () ;任意曲线变多段线一般只用于椭圆;圆弧和样条曲线 (VL-LOAD-COM)(setvar "cmdecho" 0) (setq ss (ssget '((0 . "ARC,*LINE,ELLIPSE")))) (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)));取出周长的小数值 (setq lst1(vlax-curve-getPointAtDist obj 0));取开始点 (repeat (fix zc);循环周长取整次刚好到端点 ;(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 (1+ j));递增1 );内循环结束 ;(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) ) |