File is attached.
Following code is applied :-
(defun c:test ()
(setq ent1 (car (entsel)))
(setq ent2 (car (entsel)))
(setq obj1 (vlax-ename->vla-object ent1))
(setq obj2 (vlax-ename->vla-object ent2))
(setq pts (LM:GetIntersections obj1 obj2 acExtendNone))
(princ "\nNumber of intersections : ")
(princ (length pts))
(if (> (length pts) 1)
(progn (princ "\nDistance between intersections : ") (princ (distance (car pts) (cadr Pts))))
)
(princ)
)
;;-----------------=={ Get Intersections }==------------------;;
;; ;;
;; Returns a list of all points of intersection between ;;
;; two objects ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; obj1, obj2 - VLA-Objects ;;
;;------------------------------------------------------------;;
;; Returns: List of intersection points, or nil ;;
;;------------------------------------------------------------;;
(defun LM:GetIntersections (obj1 obj2 ExtendOption)
(LM:GroupByNum (vlax-invoke obj1 'IntersectWith obj2 ExtendOption) 3)
)
;;-----------------=={ Group by Number }==--------------------;;
;; ;;
;; Groups a list into a list of lists, each of length 'n' ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; l - List to process ;;
;; n - Number of elements by which to group the list ;;
;;------------------------------------------------------------;;
;; Returns: List of lists, each of length 'n' ;;
;;------------------------------------------------------------;;
(defun LM:GroupByNum (l n / r)
(if l
(cons (reverse (repeat n
(setq r (cons (car l) r)
l (cdr l)
)
r
)
)
(LM:GroupByNum l n)
)
)
)