判断点是否在多边形区域内的AutoLISP程序
程序员文章站
2022-04-22 08:23:19
...
本代码根据网上某网友代码稍作修改,版权归原作者所有^_^!
(defun pt_inorout (regionObj pt / pt_list e1 pt n i j va va_count)
(setq pt_list (mapcar 'cdr
(vl-remove-if
'(lambda (x) (/= 10 (car x)))
(entget (car regionObj))
)
)
)
(setq i 0
va_count 0
n (length pt_list)
pt_list (append pt_list (list (car pt_list)))
)
(repeat n
(setq va (- (angle pt (nth i pt_list))
(angle pt (nth (1+ i) pt_list))
)
)
(cond ((> va pi) (setq va (- va pi)))
((< va (* -1 pi)) (setq va (+ va pi)))
)
(setq va_count (+ va_count va)
i (1+ i)
)
)
(if (< (abs (- (abs va_count) pi)) 0.000001)
't
'nil
)
)
(defun c:tt ()
(setq lst (entsel)
pt (getpoint)
)
(pt_inorout lst pt)
)