No. Unable to get actual shape of the frame. This alert is giving me as "TextFrame". Is it really impossible to get shape of the textframe? Because when oval or polygon is assigned text, its constructor.name gies textframe.

I would suspect that you are going to have to analyze the pathPoint collection and do a little math deduction…

A few observations on that:

All text frames with three points are triangular. Except when two points overlap, of course. Oh, and one of the points lies exactly on the line between the two other points (at its most extreme, that is the same as the other exception; the maths don't care).

All rectangles have four points but not all text frames with four points are rectangles. That's only true for p1..p4 if for all p(n)-p((n+1) mod 4) either their x coordinate OR their y coordinate is the same. This condition should be reversed for all subsequent points; and, again, points may not coincide nor fall on the path between two other points.

Is a 45 degrees rotated text frame still a valid rectangle?

Ovals ... now there is a challenge. An oval is just a circle with uneven horizontal and vertical axes, and thus its mathematical description is straightforward. Alas: InDesign does not really draw accurate ovals (nor circles, by the way). It uses Bezier curves that approximate them, and I have no idea how accurate that approximation is. You need to know that to be able to differentiate between 'a regular InDesign "oval"' and 'any shape with lots of bezier curves'.

If all you have is three text frames, one of which is a rectangle, the other a triangle, and the third an oval, these tests are all you need. If you may have *any* sort of text frame and want to know the 'best match' shape, you are in heaps of trouble -- what about a pentagon or a hexagon?