求点集表中到指定图元最近的点
请教各位大师已知点集表和一个曲线类图元
求点集表中到指定图元最近的点
谢谢
本帖最后由 caoyin 于 2019-10-4 09:27 编辑
(defun getClosestPoint (CRV PLST / DST PNT)
(foreach P PLST
(setq D (distance (vlax-curve-getClosestPointTo CRV P) P))
(if (or (not DST) (< D DST))
(setq DST D
PNT P
)
)
)
PNT
);;测试
(getClosestPoint (car(entsel "\n选择曲线"))
(while (setq p (getpoint "\n拾取点"))
(setq PTS (cons P PTS))
)
)
caoyin 发表于 2019-10-4 09:23
(defun getClosestPoint (CRV PLST / DST PNT)
(foreach P PLST
(setq D (distance (vlax-curve-ge ...
谢谢您的热心指导
我再好好学习一下
衷心感谢您 (defun getclosetpoint(crv pt)
(nth(car(vl-sort-i(mapcar'(lambda(x)(distance(vlax-curve-getClosestPointTo crv x)x))pt)'<))pt)
) llsheng_73 发表于 2019-10-11 15:33
谢谢您的指导
您的写法经典简洁
谢谢您 4楼的代码,vl-sort-i mapcar是两次遍历点集。 顶一下,嘿嘿
页:
[1]