4 Replies Latest reply on Oct 29, 2015 5:22 PM by K159

    How to mode change and get text frame coordinates?

    K159 Level 1

      Hi.

       

       

      There are two questions.

       

       

      1. How to mode change using JavaScript?  write -> selection

        --->  

       

       

       

       

       

      2. How to get text frame coordinates?

       

       

      Thanks.

        • 1. Re: How to mode change and get text frame coordinates?
          Jump_Over Level 5

          Hi,

           

          "Changing mode" means changing selection, I guess.

          So - you need to assign different object(s) to app.selection:

          1. app.selection = someTextFrame.insertionPoints[mIP];

               where mIP is an index of insertionPoint where you need to place a cursor

          2. app.selection = someTextFrame;


          Read someTextFrame.geometricBounds to find out its coordinates .

           

          Jarek

          • 2. Re: How to mode change and get text frame coordinates?
            TᴀW Adobe Community Professional & MVP

            1. app.toolBoxTools.currentTool = UITools.SELECTION_TOOL;

             

            2. f.geometricBounds (where f is your text frame).

            • 3. Re: How to mode change and get text frame coordinates?
              Laubender Adobe Community Professional & MVP

              Hi,

               

              do you want to select the text frame(s) of a selected insertion point or text?

              Or do you want to read out the geometric bounds (or some coordinates) of the text frame(s) where some text is selected?

               

              Reading out the geometric bounds:

               

               

              //Prepare the result array:
              var myGeoBoundsArray = [];
              
              //The selected text. Could be one single insertion point
              //or more selected text:
              var mySelectedText = app.selection[0];
              
              //If your selected text will span several text frames,
              //you'll get more than one single text frame:
              var myTextFramesArray = mySelectedText.parentTextFrames;
              
              //Loop through the result array.
              //Gather the geometricBounds of all text frames:
              for(var n=0;n<myTextFramesArray.length;n++){
                  myGeoBoundsArray.push(myTextFramesArray[n].geometricBounds);
                  };
              
              //Write the result to the JavaScript Console
              //of the ESTK (ExtendScript Toolkit App):
              $.writeln(myGeoBoundsArray.join("\r"));
              
              //Process the result array next:
              //myGeoBoundsArray
              
              //Whatever you want to figure out here.
              //I don't know from your description.
              

               

              The selection itself would stay as it is. A text selection.

              No need to select the text frame(s) of the selected text, if you want to find out the geometric bounds.

               

              Uwe

              • 4. Re: How to mode change and get text frame coordinates?
                K159 Level 1

                Thanks all.