The shortest way could be this way I believe.
(defun c:Test (/ p1 p2 p3 ss c1 c2 sr nw cd)
;; Tharwat - 29.Sep.2020 ;;
(and
(or (/= 4
(logand
4
(cdr
(assoc 70 (entget (tblobjname "LAYER" (getvar 'CLAYER))))
)
)
)
(alert "Current layer is locked!. Unlock then try again.")
)
(setq p1 (getpoint "\nSpecify end point of first polyline : "))
(or (setq ss (ssget p1 '((0 . "LWPOLYLINE"))))
(alert "No LWpolyline found at that point. Try again.")
)
(setq c1 (mid_ ss))
(setq p2 (getcorner "\nSpecify end point of second polyline : " p1))
(or (setq ss (ssget p2 '((0 . "LWPOLYLINE"))))
(alert "No LWpolyline found at that point. Try again.")
)
(setq c2 (mid_ ss))
(setq st (entlast)
cd (vlax-get-acad-object)
)
(progn
(vl-cmdf "_.RECTANG" "_none" p1 "_none" p2)
(if (/= st (setq nw (entlast)))
(progn
(vla-ZoomExtents cd)
(command "_.-boundary"
"_none"
(mapcar '(lambda (j k) (/ (+ j k) 2.0)) c1 c2)
""
)
(entdel nw)
(vla-Zoomprevious cd)
)
)
)
)
(princ)
) (vl-load-com)
(defun mid_ (ss / ent len mid)
(setq ent (ssname ss 0)
len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))
mid (vlax-curve-getpointatdist ent (/ len 2.0))
)
mid
)