434939575 发表于 2016-7-24 21:15:27

判断点在曲线内上外

(defun c:ttt () ;2016-7-21 冯蔡路口判断点在曲线的位置,曲线可以相交
(setq na (car (entsel "pick")))
(setq pt (getpoint "point"))
(setq p (vlax-curve-getClosestPointTo na pt))
       (setq p5 (mid na))
(setq cur_p5 (distance p5 p))
(setq pt_p5 (distance p5 pt))
(if (equal cur_p5 pt_p5 0.00001)
    (progn (setq pt_site 0) (princ "在曲线上"))
    (progn (if (> cur_p5 pt_p5)
   (progn (princ "在曲线内部") (setq pt_site -1))
   (progn (princ "在曲线外部") (setq pt_site 1))
   )
    )
);if
   
)
(defun mid (ss0 / ptmi ptma)
(vla-getboundingbox
    (vlax-ename->vla-object ss0)
    'ptmi
    'ptma
)
(setq 2pts (mapcar 'vlax-safearray->list (list ptmi ptma)))
(mapcar '(lambda (X Y) (/ (+ X Y) 2.0))
(car 2pts)
(cadr 2pts)
)
)

xyp1964 发表于 2024-1-24 22:23:34


(defun PtInPtn (p pt / aa)
"PtInPtn 点在点集内 (PtInPtn pt点 ptn点集)"
(setq aa (mapcar '(lambda (x y) (rem (- (angle x p) (angle y p)) pi)) pt (cons (last pt) pt))
        aa (abs (apply '+ aa))
)
(equal aa pi 1e-8)
)

ysq101 发表于 2016-7-24 21:47:14

楼主都这么厉害了?? 我记得一年前你没这么厉害啊

陈进佳 发表于 2016-7-24 22:17:08

.....扯......

陨落 发表于 2016-7-25 13:27:05

.....扯......局限性太大

preone 发表于 2024-1-24 21:43:24

用ssget选择后获取图元名,在传给这个函数,会出现:错误: 参数类型错误: 二维/三维点: nil@434939575
页: [1]
查看完整版本: 判断点在曲线内上外