Skip to main content
Legend
February 13, 2013
Question

parent page or spread?

  • February 13, 2013
  • 2 replies
  • 1444 views

I'm fiddeling around with this one and i beg for some help:

set currSelection to object reference of item 1 of selection --Script will only be used when text is marked

set parentTextFrame to item 1 of (parent text frames of currSelection)

set parentPage to parent page of parentTextFrame --Get the page

set theLine to make graphic line at parentPage with properties {geometric bounds:{A, B, C, D}, stroke color:"Linecolor", stroke weight:1}

This works fine. But only if the textbox is on a page. But often I prepare those textboxes left/right offpage on the spread for late usage – then the script doesn' work, because parent page returns nothing, and i cant just exchange that with parent spread. I dont't know how to draw the line there. Further I don't know, if a spread belongs to/has a page number: My document has more than one pages, and the line should be drawed over that marked text on the spread.

Can someone help me out?

This topic has been closed for replies.

2 replies

Peter Kahrel
Community Expert
Community Expert
February 13, 2013

Use just 'parent', which returns the spread:

set theLine to make graphic line at parent with properties {geometric bounds:{A, B, C, D}, stroke color:"Linecolor", stroke weight:1}

My first ever Applescript! The JavaScript version of this works fine.

Peter

DBLjanAuthor
Legend
February 13, 2013

Hm. I tried that with make … at parent and got some strange behaviour, depending on zoom, view-place…i guess. I cant describe it, but that pony doesnt do the trick.

I worked around it a bit like this, to keep the script working

if class of parentPage as string = "page" then

                        set parentPage to parent page of parentTextFrame

                    else

                        set parentPage to parent of parentTextFrame

                    end if

Also, when the box is on the right side of the right page, the line's x is put at the left page:
I dont really understand, what my textbox's "parent" is nor why i cant make graphic line over where my box actually is.

Community Expert
February 13, 2013

@DBLjan – Hm, maybe you are running in a trap with the coordinate system, that is set to single pages.
You have to define your coordinate system to Spread beforehand, I think…

Uwe

Community Expert
February 13, 2013

@DBLjan – the parent of the text frame is the Spread object (at least in JavaScript/ExtendScript, but should also work with AppleScript). I'm not into AppleScript, so I can give no further hints when it comes to exact syntax…

Hope, that helps!

Uwe