<br/>- ;判断 点 与 曲线关系 -1:曲线内 0:曲线上 1:曲线外<br/>(defun EF-Curve-ptInside ( ent pt / Count TmpRay) <br/> (setq randAngle (* (/ (ef-rand 3) 500) pi)) ;取 随机 角度<br/> (if (equal pt (vlax-curve-getClosestPointTo ent pt) 1E-6) <br/> 0 ;点在直线上<br/> (progn<br/> (setq ent (vlax-ename->vla-object ent))<br/> (setq tmpRay (vlax-ename->vla-object<br/> (entmakex (list '(0 . "RAY")<br/> '(100 . "AcDbEntity")<br/> '(100 . "AcDbRay")<br/> (cons 10 pt)<br/> (cons 11 (list (cos randAngle) (sin randAngle) 0))<br/> )<br/> )<br/> )<br/> )<br/> (setq pt (vlax-3D-Point pt))<br/> (setq Count 0)<br/> ;;可根据需要调整扫描角度提高检索速度,本程序采用60度<br/> (repeat 6<br/> (vla-rotate TmpRay pt (/ PI 3))<br/> ;;下面这句可以看到扫描过程,实际使用时可以注释掉 <br/> ; (COMMAND "delay" 100)<br/> (if (zerop<br/> (rem<br/> (length<br/> (vlax-invoke ent 'IntersectWith TmpRay acExtendNone) <br/> )<br/> 6<br/> )<br/> )<br/> (setq Count (1- Count))<br/> (setq Count (1+ Count))<br/> )<br/> )<br/> (vla-delete TmpRay)<br/> (if (minusp Count)<br/> 1<br/> -1<br/> )<br/> )<br/> )<br/> )
射线法判断,采用随机起始角度,以减少误判可能性 支持曲线 |