明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1316|回复: 2

[已解答] 任意曲线的垂线

[复制链接]
发表于 2013-12-6 12:32 | 显示全部楼层 |阅读模式
1明经币
下面的程序是做任意曲线的垂线,但是在用户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坐标!
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2013-12-6 12:32 | 显示全部楼层
给个简单的解决方法:
在程序开始加上 (command "_.ucs" "")
程序结束时加上 (command "_.ucs" "_P")

产生问题的根源:
在屏幕选取对象时得到的坐标是UCS坐标,需转换为WCS坐标!vlax-curve-getClosestPointTo 需要WCS坐标,返回的也是WCS坐标!
回复

使用道具 举报

 楼主| 发表于 2013-12-11 12:20 | 显示全部楼层
Gu_xl 发表于 2013-12-6 12:32
给个简单的解决方法:
在程序开始加上 (command "_.ucs" "")
程序结束时加上 (command "_.ucs" "_P")

谢谢斑竹~~~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-17 18:13 , Processed in 0.186898 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表