InDesign Obj Hierarchy-What rectangle is picture really in?

I want to do something with the containing rectangles of all pictures in an InDesign CS document. So, I step through all the links and grab their grandparents:

tell application "InDesign CS"
	tell document 1
		repeat with linkNo from 1 to count of links
			set pictur to parent of link linkNo -- up first level
			set rectang to parent of pictur -- up second level
			set {tt, ll, bb, rr} to geometric bounds of rectang
			-- do stuff with these coordinates, specifically center a small text box over it
		end repeat
	end tell
end tell

But I came across a document where I had to go up three levels instead of two:

set pictur to parent of link linkNo -- up first level
set rectang1 to parent of pictur -- up second level
set rectang2 to parent of rectang1 -- up third level
set {tt, ll, bb, rr} to geometric bounds of rectang

The only reason I knew to go up three levels was that I knew what bounds to expect from a visual check.

This was a customer document so I don’t know how it was put together, and I (obviously) don’t know InDesign well at all. Can I determine scriptically what rectangle a picture really is in? Would it always work to keep ascending until I move past all rectangles (or polygons or ???) and then move back one level? Or (here’s an ugly thought) must I take the intersection of all containing rectangles? Or maybe it’s impossible?

Thanks for reading this far…

  • Dan

Looking back at this I think I should have stated things more clearly. What I really want is to get the center of the part of the picture that is visible in the document. Restating it that way makes me think that the intersection of all containing rectangles and polygons is what’s necessary. Does anyone have any ideas about this?

Thanks…

  • Dan