Re: Three InDesign scripting questions
Re: Three InDesign scripting questions
- Subject: Re: Three InDesign scripting questions
- From: Shane Stanley <email@hidden>
- Date: Tue, 28 Feb 2006 20:21:46 +1100
- Thread-topic: Three InDesign scripting questions
On 28/2/06 2:55 PM, "Stockly, Ed" <email@hidden> wrote:
> It's very easy in Quark to get the object reference of the page that a text
> box or picture box is on. Can that be done with inDesign? The page items have
> a "parent," but that's always the spread or document, which doesn't help.
>
> Can a script identify which page a page item is on?
The parent of a page item will be either a spread (if the item is fully
outside the page boundaries), a page (the page it's "mostly" on), a group,
or a character (for inlines). So you basically need to get the class of the
parent; if it's a page, get the name; if it's a spread, it's not on a page;
if it's a group, do the same with its parent; and if it's a character, get
item 1 of the parent text frames of the parent, and do the same with it's
parent. Fiddly, but not as bad as it sounds.
So something like this:
tell application "Adobe InDesign CS2"
set theItem to item 1 of selection
repeat
set theClass to class of parent of theItem
if theClass = page then
set pageName to name of parent of theItem
exit repeat
else if theClass = spread then
set pageName to "spread"
exit repeat
else if theClass = group then
set theItem to parent of theItem
else if theClass = character then
parent of theItem
set theItem to item 1 of (get parent text frames of parent of
theItem)
end if
end repeat
display dialog pageName
end tell
--
Shane Stanley <email@hidden>
AppleScript Pro Sessions NJ May 06 <http://www.scriptingmatters.com/aspro>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden