4 Replies Latest reply on Oct 13, 2009 2:00 PM by anrkeytek

    Moving objects incrementally based on page number

    anrkeytek

      Hey all,

       

      Trying to automate a group of objects moving down a page, driven by the page location in a book.

       

      New to scripting, just need some pointers on best practise, gotchas etc.

       

      Any thoughts?

        • 1. Re: Moving objects incrementally based on page number
          ramkumar.vp

          Hi Anrkeytek,


          What do you mean by "Page location"???


          I think you want to move the group of frames to SLUG area.


          Regards,

          Ramkumar

          • 2. Re: Moving objects incrementally based on page number
            anrkeytek Level 1

            Hey ramkumar,

            I want a graphic object to be high on a page on page 1 of a book, 

            moving down so that it is near bottom of page by end of book. Halfway 

            thru book, halfway down page for example.

             

            So my question is how do I have the page number affect the vertical 

            (y) position of an object?

             

            Cheers,

            D

            • 3. Re: Moving objects incrementally based on page number
              [Jongware] Most Valuable Participant

              Using a script doesn't make it 'live', the object will not be 'affected' after you move it once. But apart from that, it's pretty simple.

               

              Given a current page number n, a number of pages ntot, a page height h, and an object height oh, you can use this calculation for the top position:

               

              topy = n*(h oh)/ntot

               

               

              You can change an object's y position by writing the value into its geometricBounds array:

               

              var myBounds = someFrame.geometricBounds;

              myBounds[2] = myBounds[2] - myBounds[0] + topy;

              myBounds[0] = topy;

              someFrame.geometricBounds = myBounds;

               

              As you can see, you have to read and write the array in one single piece. You need to change two elements: number [0] holds the top y position, number [2] holds the bottom y position. As you can see, you have to 'calculate' the bottom first, based on the top (A good alternative is using the move function but I can't write that from the top of my head.)

              • 4. Re: Moving objects incrementally based on page number
                anrkeytek Level 1

                ok that's given me some clues.

                 

                Ill try and get my head around the move function as there will be several

                hundred pages and that may alter.

                so trying to avoid adjusting objects on every page before print.

                 

                if i understand you correct i could just insert the object at same place on

                every page with code in its geometricBounds array then at end of production

                I'll run the script?

                 

                sorry I should try it first. I'll start playing.

                 

                Cheers matey, nice response, ta

                 

                D