The following is my solution
Only for pline consist of line
by can deal with not only convex pline , but also concave pline.
The Algorithm is as in the gif
(I am not sure whether chlh_jd has the same algorithm, because I see 1e20
)
OK, It is late to go to bed, byebye~~
;;;; get the vertex of the polyline
(defun q:ent:lwpolyline:vertex (ent / pt_list)
(foreach x ent
(if (= (car x) 10)
(setq pt_list (append(list (cdr x))pt_list))))
pt_list
)
;;;; To deal the intersection of each two set
(defun q:q1:deal1(plst1 plst2 ang / a b)
(setq a (q:q1:deal2 plst1 plst2 ang))
(setq b (q:q1:deal2 plst2 plst1 (+ ang 3.1415926535897)))
(if (< (cadr a) (cadr b)) (setq a b))
a
)
;;;;
(defun q:q1:deal2(lst1 lst2 ang / dis dis1 i lst1a p res x x1 y)
(setq lst1a (reverse (cons (car lst1) (reverse (cdr lst1)))))
(foreach x lst2
(setq x1 (polar x ang 1e7) i 0)
(foreach y lst1
(if (setq p (inters x x1 y (nth i lst1a)))
(if (> (setq dis1 (distance p x)) dis) (setq res p dis dis1))
)
(setq i (1+ i))
)
)
(list res dis)
)
;;;;; Main function
(defun c:tt( / a ang lst1 lst2 o1 o2 res)
(setq o1 (car (entsel "\nObject 1: "))
o2 (car (entsel "\nObject 2: "))
ang (getangle "\nMove Angle: ")
lst1 (q:ent:lwpolyline:vertex (entget o1))
lst2 (q:ent:lwpolyline:vertex (entget o2))
res (q:q1:deal1 lst1 lst2 ang))
(princ "\n res = ") (princ res);Erase_DV
(if (setq a (car res))
(vla-move (vlax-ename->vla-object o2)
(vlax-3D-point a)
(vlax-3D-point (polar a ang (cadr res)))
))
(princ)
)
(princ "\n By qjchen")