Hopefully this is the one you are after.
Code:
(defun c:Test (/ int sel ent pts pt1 pt2 pt3 pt4 sg1 sg2 1pt 2pt )
;;----------------------------------------------------;;
;; Author : Tharwat Al Choufi ;;
;; website: https://autolispprograms.wordpress.com ;;
;;----------------------------------------------------;;
(and (princ "\nSelect closed polylines to draw centerline on longest segment : ")
(setq int -1 sel (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1))))
(while (setq int (1+ int) ent (ssname sel int))
(foreach itm (entget ent)
(and (= (car itm) 10)
(setq pts (cons (cdr itm) pts))
)
)
(mapcar 'set '(pt1 pt2 pt3 pt4) pts)
(and (equal (distance pt1 pt3) (distance pt2 pt4) 1e-2)
(or (and (> (setq sg1 (distance pt1 pt2)) (setq sg2 (distance pt2 pt3)))
(setq 1pt (polar pt2 (angle pt2 pt3) (/ sg2 2.0))
2pt (polar pt1 (angle pt1 pt4) (/ sg2 2.0))
)
)
(setq 1pt (polar pt1 (angle pt1 pt2) (/ sg1 2.0))
2pt (polar pt3 (angle pt3 pt4) (/ sg1 2.0))
)
)
(entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0)
'(8 . "EPCENTER") (cons 10 1pt) (cons 10 2pt))))
(setq pts nil)
)
)
(princ)
)