• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Three InDesign scripting questions (page item parent)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Three InDesign scripting questions (page item parent)


  • Subject: Re: Three InDesign scripting questions (page item parent)
  • From: Peter Waibel <email@hidden>
  • Date: Tue, 28 Feb 2006 14:57:18 +0100


Am 28.02.2006 um 10:21 schrieb Shane Stanley:


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.



The page items parent can be in a hierachy like

spread
page
page item 
group
..........
page item

You need a recurse handler to find the parent at top of the hierachy.

Try this:

tell application "InDesign CS"
tell document 1
set myPageItemRef to object reference of page item 1
return my GetSpreadPageInfo_GivenPageItemRef(myPageItemRef)
end tell
end tell
(*
-->{
spreadIndex:1, 
spreadRef:spread id 148 of document "Unbenannt-1" of application "InDesign CS", 
groupIdList:{}, 
pageIndex:1, 
pageRef:page id 153 of spread id 148 of document "Unbenannt-1" of application "InDesign CS", 
pageWidth:209.999999999936, 
pageHeight:296.999999999461
}
*)


on GetSpreadPageInfo_GivenPageItemRef(thisArgs)
set myMsgSubHead to "GetSpreadPageInfo_GivenPageItemRef(3000) "
--
-- returns: record, {spreadIndex:"", pageIndex:"", pageWidth:"", pageHeight:"",pageRef:{},spreadRef:{}}
--
-- thisArgs: indd object reference page item
--
try
-- GetSpreadPageInfo_GivenPageItemRef(thisArgs)
-- wird mit einem einzigen Argument thisArgs aufgerufen.
-- Bei der anschliessenden Rekursion muss ein Zwischenergebnis 
-- als weiteres Argument weitergereicht werden.
-- Fuer den 2. und jeden weiteren Aufruf wird eine Liste als Argument uebergeben.
if class of thisArgs is not list then
set myObjRef to thisArgs
set myResultRec to {spreadIndex:"", spreadRef:"", groupIdList:{}, pageIndex:"", pageRef:"", pageWidth:"", pageHeight:""}
else
set myObjRef to item 1 of thisArgs
set myResultRec to item 2 of thisArgs
end if
---------------------------------------------------------------------------------------------------------


tell application "InDesign CS"
if class of myObjRef is group then
set beginning of groupIdList of myResultRec to id of myObjRef
end if
if class of myObjRef is page then
set parentClass to class of parent of myObjRef
if parentClass is spread then
set pageRef of myResultRec to myObjRef
set pageWidth of myResultRec to (item 4 of bounds of myObjRef) - (item 2 of bounds of myObjRef)
set pageHeight of myResultRec to (item 3 of bounds of myObjRef) - (item 1 of bounds of myObjRef)
set spreadIndex of myResultRec to (index of parent of myObjRef)
set spreadRef of myResultRec to (parent of myObjRef)
set pageIndex of myResultRec to (index of myObjRef)
return myResultRec
else
error "Expected that parent of page is a spread but found parent class: " & parentClass
end if
else
set newObjRef to object reference of parent of myObjRef
my GetSpreadPageInfo_GivenPageItemRef({newObjRef, myResultRec})
end if
end tell
on error errMsg number errNum from errObj partial result errPartialSuccess to errClass
error myMsgSubHead & errMsg
end try
end GetSpreadPageInfo_GivenPageItemRef


Peter
 _______________________________________________
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

  • Follow-Ups:
    • Re: Three InDesign scripting questions (page item parent)
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Three InDesign scripting questions (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Folder Action - duplicating files
  • Next by Date: Re: Folder Action - duplicating files
  • Previous by thread: Re: Three InDesign scripting questions
  • Next by thread: Re: Three InDesign scripting questions (page item parent)
  • Index(es):
    • Date
    • Thread