5 Replies Latest reply on Feb 13, 2013 6:47 AM by DBLjan

    parent page or spread?

    DBLjan Level 2

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

       

      Bildschirmfoto 2013-02-13 um 13.12.12.png

       

      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?

        • 1. Re: parent page or spread?
          Laubender Adobe Community Professional & MVP

          @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

          • 2. Re: parent page or spread?
            Peter Kahrel Adobe Community Professional & MVP

            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

            • 3. Re: parent page or spread?
              DBLjan Level 2

              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.

              • 4. Re: parent page or spread?
                Laubender Adobe Community Professional & MVP

                @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

                • 5. Re: parent page or spread?
                  DBLjan Level 2

                  I made some more adjustments, and this seems to work. I dont know exactly why, but: mates, i think we got this.

                   

                  I googled some code which helped someone to create cropmarks on documents with different zero points and came to this:

                   

                  set rulerOrigin to ruler origin of view preferences

                    if rulerOrigin is not spread origin then set ruler origin of view preferences to spread origin --(spread origin/page origin/spine origin)

                  set rulerZeroPoint to zero point

                    if rulerZeroPoint is not {0, 0} then set zero point to {0, 0}

                   

                  --> Here I nested my code, the fetching of the coordinates (like set Y1 to baseline of first character in selection) and the drawing of the line.

                   

                  --> And set it back:

                  set zero point to rulerZeroPoint

                  set ruler origin of view preferences to rulerOrigin