谢谢飞鸟兄的函数
以前,出于对grread的无法捕捉和正交等原因,经常寻找改进这个的方法,所以,经常用一个画曲线上的垂直线的例子来练写代码。
以前利用Alexander Rivilis的DynDraw.Arx函数
http://www.theswamp.org/index.php?topic=9133.0
编写过这个函数
http://www.theswamp.org/index.php?topic=9133.msg395251#msg395251
而后,又采用了.Net的Jig函数来编写这个效果
http://bbs.mjtd.com/thread-84961-1-1.html
Highflybird兄的这个新的Arx出来之后,一直没有时间仔细学习,昨晚在认真学习并请教了高飞兄之后,写下如下代码,可以看出,相比Alexander的DynDraw函数,高飞兄的Arx编写思路更加清晰,代码可以更短。
在此向高飞兄表达崇高的敬意
- ;;; Thanks to Highflybird very much
- ;;; 寻找曲线上点的垂直线.
- ;;; 请先加载Highflybird兄的好函数
- ;;;
- (defun C:test (/ curve l)
- (prompt "\n 请先选择一个曲线:")
- (setq curve (vlax-ename->vla-object (car (entsel)))
- l (vla-addline (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
- (vlax-3D-point '(0 0 0))(vlax-3D-point '(0 0 0)))
- )
- (ssjig "dyn_call_back" "\n 请选择一点: " "" (+ 1 2 128) 0)
- (princ)
- )
- ;;;;画垂直线
- (defun dyn_call_back (p / p1 p2)
- (setq p1 (vlax-curve-getClosestPointTo curve p)
- p2 (polar p1 (+ (/ pi 2) (angle '(0 0 0)
- (vlax-curve-getFirstDeriv curve (vlax-curve-getParamAtPoint curve
- (vlax-curve-getClosestPointTo curve p))))) (* 0.3 (getvar "viewsize")))
- p2a (mapcar '+ p1 (mapcar '- p1 p2)))
- (if (< (distance p p2) (distance p p2a))
- (progn (vlax-put l 'StartPoint p1) (vlax-put l 'EndPoint p2))
- (progn (vlax-put l 'StartPoint p1) (vlax-put l 'EndPoint p2a))
- )
- )
- (princ "\n By [email]qjchen@gmail.com[/email], 利用Highflybird兄的函数,过一点画垂直线,动态,命令test")
- (princ)
|