任意曲线的垂线
下面的程序是做任意曲线的垂线,但是在用户ucs下不能使用,哪位帮忙解决一下,多谢了;;;*************************************
(defun C:ayPerCurve1(/ xEntPick entName pickPt entData startPt endPt p1 p2 tempPT angofLine lenPerLine tanAngle)
(while (not (and (setq xEntPick (entsel "\n选择曲线: ")))))
(setq entName (car xEntPick))
(setq pickPt (cadr xEntPick))
(setq entData (entget entName))
(redraw entName 3)
(grdraw pickPt pickPt -1 1)
(setq startPt (getpoint (strcat "\n指定垂足点<默认拾取点>: " )))
(if (null startPt) (setq startPt pickPt))
(setq startPt (vlax-curve-getClosestPointTo entName startPt nil))
(setq lenPerLine (getdist startPt "\n指定垂线长: "))
(setq tanAngle (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv entName
(vlax-curve-getparamatpoint entName
(vlax-curve-getclosestpointto entName startPt)))))
(setq p1 (polar startPt (+ tanAngle (/ PI 2.0)) lenPerLine))
(setq p2 (polar startPt (- tanAngle (/ PI 2.0)) lenPerLine))
(ayOSMode nil);关闭捕捉.
(vl-cmdf "_.Line" P1 P2 "")
(redraw entName 4)
);end_defun
;;;**************************
;;; No.0 对象捕捉开关 函数
;;;**************************
(defun ayOSMode (isOpenSnap)
(if isOpenSnap
(setvar "osmode" (rem (getvar "osmode") 16384));打开捕捉.
(setvar "osmode" (+ (rem (getvar "osmode") 16384) 16384));关闭捕捉.
);end_if
给个简单的解决方法:
在程序开始加上 (command "_.ucs" "")
程序结束时加上 (command "_.ucs" "_P")
产生问题的根源:
在屏幕选取对象时得到的坐标是UCS坐标,需转换为WCS坐标!vlax-curve-getClosestPointTo 需要WCS坐标,返回的也是WCS坐标! Gu_xl 发表于 2013-12-6 12:32 static/image/common/back.gif
给个简单的解决方法:
在程序开始加上 (command "_.ucs" "")
程序结束时加上 (command "_.ucs" "_P")
谢谢斑竹~~~~
页:
[1]