判断点在线上
(defun donpl( pt plname / vlist p1 p2 x1 x2 y1 y2 a b xt yt ax n)(setq vlist (vl-remove-if'not(mapcar'(lambda(x) (if (= (car x) 10) (cdr x))) (entget plname))))
(setq n 0)
(while (and p2 (not jg))
(setq p1 (nth n vlist)
p2 (nth (+ n 1) vlist)
x1 (car p1)
y1 (cadr p1)
x2 (car p2)
y2 (cadr p2)
a (/ (- y1 y2) (- x1 x2))
b (- y1 (/ (* x1 (- y1 y2)) (- x1 x2)))
xt (car pt)
yt (cadr pt)
ax (+ (* xt a) b)
)
(setq jg (equal ax yt 0.001))
(setq n (1+ n))
)
jg
)
(equal pt (vlax-curve-getClosestPointTo plname pt) 0.000001) cghdy 发表于 2022-2-16 16:30
能否区分在线上和在延长线上
(setq on1 (equal pt (vlax-curve-getClosestPointTo plname pt) 0.000001))
(setq on2 (equal pt (vlax-curve-getClosestPointTo plname pt t) 0.000001))
(cond
((and on1 on2) (princ "在线上"))
((and (not on1) on2) (princ "在延长线上"))
(t (princ "在线外"))
) lijiao 发表于 2018-8-31 14:19
新手函数太少,谢谢大神指点,万分感谢 lijiao 发表于 2018-8-31 14:19
这个写好可惜我不会VL 谢谢楼主分享!!!!!! lijiao 发表于 2018-8-31 14:19
能否区分在线上和在延长线上 cghdy 发表于 2022-2-16 16:30
能否区分在线上和在延长线上
要判断是否在延长线上,最简单的办法是在P点产生一根直线,用vla-IntersectWith来判断。 lijiao 发表于 2022-2-17 11:33
好办法:handshake 自贡黄明儒 发表于 2022-2-17 08:34
要判断是否在延长线上,最简单的办法是在P点产生一根直线,用vla-IntersectWith来判断。
lijiao回复的vlax-curve-getClosestPointTo是带了这个功能的
页:
[1]
2