4 Replies Latest reply on Sep 2, 2016 3:59 PM by Obi-wan Kenobi

    Problem of geometric bounds! …

    Obi-wan Kenobi Level 5

      Hi all,


      My Doc has the same page format with a similar text frame on each page and it has several pages!

      I have a loop on the results of a grep find/replace.


      With this:


      for (i = 0; i < myFound.length; i++)
             var myFrame = myFound[i].parentTextFrames[0];
             var myBaseline = myFrame.geometricBounds[2] - myFound[i].baseline; 


      I would like to calculate myBaseline, but I get an error on line 04.


      Capture d’écran 2016-09-02 à 21.22.29.png


      In fact, what I want to get the position of text by reference at the bottom of its text frame!


      Thanks in advance!


      (^/)  [tired tonight!]

        • 1. Re: Problem of geometric bounds! …
          Skemicle Level 3

          I set myFound to app.selection and this gives the distance from the baseline of the selection to the bottom of the text frame. So I'm thinking that if you insert app.selection = myFound[i] before your myBaseline variable and change myFound[i].baseline; to app.selection.baseline It may work.. but i haven't really done anything with grep find/replace in scripts so i don't know how to go about testing my theory... (yet) =P

          • 2. Re: Problem of geometric bounds! …
            Obi-wan Kenobi Level 5

            Hi Skemicle! 


            The selection is OK with this! … But apparently the problem seems to be on the line 03.


                   var myFrame = myFound[i].parentTextFrames[0];  


            Not really sure this line works! 



            • 3. Re: Problem of geometric bounds! …
              Loic.Aigon Adobe Community Professional

              Hi Michel,


              Great chances here that the text object is actually hidden. In this case, parentTextFrames length equals 0 and accessing a property of a non valid reference would throw your error.


              You may want to first check if the reference is valid through


              if ( myFound[i].parentTextFrames[0].isValid ) {

                   //do whatever you need


                  else {

                   //do something different.






              • 4. Re: Problem of geometric bounds! …
                Obi-wan Kenobi Level 5

                Hi Loïc,


                The text object wasn't hidden, but you're totally right when you said that something was not "valid"!

                The word put me on the right track! 


                The script works before I modify this point:

                Before: the script compared the "baseline" to a delimiter X

                After: it compares "bottom of the text frame - baseline" to a new delimiter Y


                What I forgot to change, below the code lines I showed, is the direction of the sign:


                if (myBaseline > myDelimiter) {




                … to:


                if (myBaseline < myDelimiter) {




                "Noodle you are, young padawan!

                to sleep, you have to go!"

                often said to me my Master Yoda!