;| BBoxOverlap.lsp The BBoxOverlap function takes two entity names as arguments and returns T if their WCS bounding boxes overlap, nil if not. by Bill Gilliss bill at realerthanreal dot com Comments and suggestions always welcome. No warranty, either expressed or implied, is made as to the fitness of this information for any particular purpose. All materials are to be con- sidered 'as-is' and use thereof should be considered as at your own risk. ver 1.0 Feb 07 2010 - initial public release Keywords: AutoCAD AutoLISP boundingbox overlap interfere interference ========================================================================= |; (defun boundingBoxOverlap (A B / Amin Amax Bmin Bmax) (vl-load-com) (vlax-invoke-method (vlax-ename->vla-object A) "getboundingbox" 'minA 'maxA) (setq Amin (vlax-safearray->list minA) Amax (vlax-safearray->list maxA) ) (vlax-invoke-method (vlax-ename->vla-object B) "getboundingbox" 'minB 'maxB) (setq Bmin (vlax-safearray->list minB) Bmax (vlax-safearray->list maxB) ) (if ;;if any of these conditions are true, then there is no overlap (or (>= (car Amin) (car Bmax)) ;A entirely to right of B (>= (cadr Amin) (cadr Bmax)) ;A entirely in back of B (>= (caddr Amin) (caddr Bmax)) ;A entirely above B (<= (car Amax) (car Bmin)) ;A entirely to left of B (<= (cadr Amax) (cadr Bmin)) ;A entirely in front of B (<= (caddr Amax) (caddr Bmin)) ;A entirely below B ) nil T ) )