xqyhome 发表于 2005-3-3 21:03:00

如何用LISP获取椭圆弧和样条曲线的长度?谢谢!

如何用LISP获取椭圆弧和样条曲线的长度?


在命令行中用LIST命令是可以查看的.

ljpnb 发表于 2005-3-3 21:21:00

这个问题我刚好做过题,不过对闭合样条曲线不行,椭圆的长度误差为0.000001



(defun c:test ()<BR>       (setq ent(car (entsel "\n 选择一个椭圆或是样条曲线: ")))<BR>       (setq obj (vlax-Ename-&gt;Vla-Object ent))<BR>       (setq name(cdr (assoc 0 (entget ent))))<BR>       (if (= name "ELLIPSE")<BR>                       (progn<BR>                                       (setq point (vlax-curve-getPointAtDist obj -0.000001))<BR>                                       (setq len (vlax-curve-getDistAtPoint obj point))<BR>                       )<BR>                       (progn<BR>                                       (setq endpoint (vlax-curve-getendpoint obj))<BR>                                       (setq len (vlax-curve-getDistAtPoint obj endpoint))<BR>                       )<BR>       )<BR>       (print (strcat "\n 当前长度为 L=" (rtos len)))<BR>       (princ)<BR>       )

ljpnb 发表于 2005-3-4 12:37:00

还有一个现成的方法:


(setq ent(car (entsel "\n 选择一个椭圆或是样条曲线: ")))<BR>(command "lengthen" ent "")<BR>(setq        len (getvar "perimeter"))

alin 发表于 2005-3-3 21:23:00

(setq curve-obj (car (entsel "\nSelect the curve:")))<BR>       (setq len (vlax-curve-getDistAtParam curve-obj (vlax-curve-getEndParam curve-obj)))

ljpnb 发表于 2005-3-3 21:41:00

还是alin版大高明。

xqyhome 发表于 2005-3-4 08:32:00

行大礼致谢!
页: [1]
查看完整版本: 如何用LISP获取椭圆弧和样条曲线的长度?谢谢!