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