How do I get dimensions of inDesign Graphics boxes?

G’day

Similar to my quark question, I’m trying to place a text box in an indesign page, clear of any embedded text or graphics.

To do this I need to determine the topmost frame, and the bottommost.

Thanks to another answer from Stefan elsewhere, I’ve got a script that will do it for text frames, but the terminology for the graphics frames eludes me.

As well, how do I determine the height of the inDesign page/document, please?

Any advice welcome

Regards

Santa


tell application "Adobe InDesign CS3"
	tell document 1
		set TopOfDoc to 0
		set BotOfDoc to 0
		repeat with oneFrame in (get text frames)
			set {A, B, c, d} to geometric bounds of oneFrame
			--set geometric bounds of oneFrame to {A, B, c, d}
			set FrameBottom to A + c
			if TopOfDoc = 0 then set TopOfDoc to A
			if BotOfDoc = 0 then set BotOfDoc to FrameBottom
			if A < TopOfDoc then set TopOfDoc to A
			if FrameBottom > BotOfDoc then set BotOfDoc to FrameBottom
		end repeat
	end tell
end tell
TopOfDoc & BotOfDoc

Hi Santa,

I recommend always to take a look into the dictionary

document has an element pages, and page has an element page items and a property bounds

There are also two great tutorial / guide PDF documents for Indesign CS 3

Adobe InDesign CS3 Scripting Guide: AppleScript
Adobe InDesign CS3 Scripting Tutorial

G’day Stefan.

Thanks for that.

I poured over the Dictionary but missed the page items link.

my script is below.

Regards

Santa


tell application "Adobe InDesign CS3"
	tell view preferences
		set horizontal measurement units to inches
		set vertical measurement units to inches
	end tell
	tell document 1
		set TopOfDoc to 0
		set BotOfDoc to null
		set LeftOfDoc to null
		repeat with oneFrame in (get page items of page 1)
			set {A, B, c, d} to geometric bounds of oneFrame
			--set geometric bounds of oneFrame to {A, B, c, d}
			if TopOfDoc = null then set TopOfDoc to A
			if BotOfDoc = null then set BotOfDoc to c
			if LeftOfDoc = null then set LeftOfDoc to B
			if A < TopOfDoc then set TopOfDoc to A
			if c > BotOfDoc then set BotOfDoc to c
			if B < LeftOfDoc then set LeftOfDoc to B
		end repeat
		if TopOfDoc > 0.65 then
			set TopOfText to TopOfDoc - 0.65
		else
			set TopOfText to BotOfDoc + 0.2
		end if
		make new text frame with properties {geometric bounds:{TopOfText, LeftOfDoc + 0.06, TopOfText + 1, LeftOfDoc + 6}}
	end tell
	tell parent story of text frame 1 of page 1 of document 1
		set contents to "(2008 12 12 04 34 56 14Z)"
		set applied font to "IDAutomationHC39M"
		set point size to 12
	end tell
end tell