24
141
115
初露锋芒
;;----------------------=={ Inside-p }==----------------------;;;; ;;;; Predicate function to determine whether a point lies ;;;; inside a supplied LWPolyline. ;;;;------------------------------------------------------------;;;; Author: Lee Mac - www.lee-mac.com ;;;; Using some code by gile (as marked below), thanks gile. ;;;;------------------------------------------------------------;;;; Arguments: ;;;; pt - 3D WCS point to test ;;;; ent - LWPolyline Entity against which to test point ;;;;------------------------------------------------------------;;;; Returns: T if supplied point lies inside supplied LWPoly ;;;;------------------------------------------------------------;;(defun LM:Inside-p (pt ent / _GroupByNum lst nrm obj tmp) (defun _GroupByNum (l n / r) (if l (cons(reverse (repeat n (setq r (cons (car l) r) l (cdr l) ) r ))(_GroupByNum l n) ) ) ) (if (= (type ent) 'VLA-OBJECT) (setq obj ent ent (vlax-vla-object->ename ent) ) (setq obj (vlax-ename->vla-object ent)) ) (setq lst (_GroupByNum (vlax-invoke (setq tmp (vlax-ename->vla-object (entmakex (list (cons 0 "RAY") (cons 100 "AcDbEntity") (cons 100 "AcDbRay") (cons 10 pt) (cons 11 (trans '(1. 0. 0.) ent 0)) ) ) ) ) 'IntersectWith obj acextendnone ) 3 ) ) (vla-delete tmp) (setq nrm (cdr (assoc 210 (entget ent)))) ;; gile: (and lst (not (vlax-curve-getparamatpoint ent pt)) (= 1 (rem(length (vl-remove-if (function (lambda (p / pa p- p+ p0 s1 s2) (setq pa (vlax-curve-getparamatpoint ent p)) (or (and (equal (fix (+ pa (if (minusp pa) -0.5 0.5 ) ) ) pa 1e-8 ) (setq p- (cond ((setq p- (vlax-curve-getPointatParam ent (- pa 1e- ) ) (trans p- 0 nrm) ) ((trans (vlax-curve-getPointatParam ent (- (vlax-curve-getEndParam ent) 1e- ) 0 nrm ) ) ) ) (setq p+ (cond ((setq p+ (vlax-curve-getPointatParam ent (+ pa 1e- ) ) (trans p+ 0 nrm) ) ((trans (vlax-curve-getPointatParam