@alsawadi.re
check this one
thank you Lee Mac for wonderful (LM:intersections) function. without it where were we? 😀
Moshe
(vl-load-com)
(defun c:tset (/ LM:intersections ; local function
pick ss0 ss1 AcDbPline AcDbText)
;; Intersections - Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;; mod - [int] acextendoption enum of intersectwith method
(defun LM:intersections ( ob1 ob2 mod / lst rtn )
(if (and (vlax-method-applicable-p ob1 'intersectwith)
(vlax-method-applicable-p ob2 'intersectwith)
(setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
)
(repeat (/ (length lst) 3)
(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
lst (cdddr lst)
)
)
)
(reverse rtn)
); LM:intersections
; here start (c:tset)
(cond
((not
(and
(setq pick (entsel "\nPick a polyline: "))
(wcmatch (cdr (assoc '0 (entget (car pick)))) "LWPOLYLINE,POLYLINE")
)
); not
(vlr-beep-reaction)
(prompt "\nobject selected is not a polyline.")
); case
((not (setq ss0 (ssget "x" '((0 . "text,mtext") (410 . "model")))))
(vlr-beep-reaction)
(prompt "\ncan find any text object.")
); case
( t
(setq AcDbPline (vlax-ename->vla-object (car pick)))
(setq ss1 (ssadd))
(vlax-for AcDbText (vla-get-activeSelectionSet (vla-get-activedocument (vlax-get-acad-object)))
(if (LM:intersections AcDbPline AcDbText acExtendNone)
(ssadd (vlax-vla-object->ename AcDbText) ss1)
)
(vlax-release-object AcDbText)
); vlax-for
(vlax-release-object AcDbPline)
(if (> (sslength ss1) 0)
(sssetfirst ss1 ss1) ; vwalla, select text(s)
)
); case
); cond
(princ)
); c:tset