been a while of not doing lisp, so just trying to add something:
a simple routine to test on lwpolylines - no error control - guess that some progn's usage are not required, but.... have fun!
(vl-load-com)
(defun rtd (a /) (* (/ a pi) 180.0))
(defun C:TST (/ e shape coords sides isShape p1 p2 p3 p4)
(setq e (car (entsel)))
(setq shape (vlax-ename->vla-object e))
(setq coords (vlax-get shape 'coordinates))
(setq sides (/ (length coords) 2))
(setq isShape "Undefined")
(if (and (eq sides 4) (vl-every 'zerop (mapcar '(lambda (i) (vla-getBulge shape i)) (list 0 1 2 3))))
(progn
(setq p1 (list (nth 0 coords) (nth 1 coords)))
(setq p2 (list (nth 2 coords) (nth 3 coords)))
(setq p3 (list (nth 4 coords) (nth 5 coords)))
(setq p4 (list (nth 6 coords) (nth 7 coords)))
(if (and (and (eq (angle p1 p2) (angle p4 p3)) (eq (angle p1 p4) (angle p2 p3)))
(or (equal (abs (rtd (- (angle p2 p3) (angle p1 p2)))) 90.0 0.001)
(equal (abs (rtd (- (angle p2 p3) (angle p1 p2)))) 270.0 0.001))) ;; is rectangle test
(progn
(setq isShape "Rectangle")
(if (equal (distance p2 p3) (distance p1 p2) 0.001) ;; test for square
(progn
(setq isShape "Square")))))))
(princ isShape) (princ))