Let's say that obj1 is the vla-object representing the xref and that obj2 is the vla-object representing a polyline that intersects with the xref one or more times.
The intersections can be obtained using:
(setq ints (vlax-invoke obj1 'intersectwith obj2 0))
Of course the result is what we call a flat list, not a list of separate points, but a list like
(x1 y1 z1 x2 y2 z2 ... xn yn zn)
I use the following function to convert the flat list into a list of 3D points:
;; Function to group a list of items into a list of
;; multiple lists, each of length N, e.g.
;; '(A B C D E F G H I) -> '((A B C)(D E F)(G H I))
(defun @group (lst n / item new)
(foreach element (reverse lst)
(setq item (cons element item))
(if (= (length item) n)
(setq new (cons item new) item nil)
)
)
new
)
The programmer must know in advance whether the flat list is 2D or 3D.
If the flat list is 3D then (setq ints (@group ints 3))
If the flat list is 2D then (setq ints (@group ints 2))
You may be surprised with the results because the intersectwith method treats things like inserts and mtext as though they were a rectangular box, just the same as the getboundingbox method. So there are likely to be fewer intersections returned than what you deduce visually. I have not yet found a way using Lisp to retrieve all the apparent intersections. I suppose it might be done by temporarily exploding the insert or mtext and trying to interpret the intersection points of each component, but I have successfully avoided such an undertaking for lack of need. It's too bad that Autodesk doesn't provide us a getboundingpolygon method.