4 Replies Latest reply on Mar 14, 2013 8:03 PM by CarlosCanto

    finding the matrix info on a text frame?

    DuanesSearchForKnowledge

      I wanted to understand the matrix values and methods so I could make a script to select or not select textframes that are angled.

      Can anyone explain this matrix stuff to me?

       

      This script is the only example I have found so far.

      if ( app.documents.length > 0 ) {

      var moveMatrix = app.getIdentityMatrix( 0.5, 1.5 );

      var totalMatrix = concatenateRotationMatrix( moveMatrix, 10 );

      var doc = app.activeDocument.activeLayer;

      for ( i = 0; i < doc.pageItems.length; i++ ) {

      doc.pageItems[i].transform( totalMatrix );

      }

      }

       

      Im thinking I need to use getRotationMatrix([angle])

      any help would be greatly appreciated,

      Duane

        • 1. Re: finding the matrix info on a text frame?
          CarlosCanto Adobe Community Professional & MVP

          here's another example using matrix properties

           

          var idoc = app.activeDocument;
          var itext = idoc.textFrames[0];
          
          var imatrix = itext.matrix;
          $.writeln(imatrix.mValueA+"\r"+imatrix.mValueB+"\r"+imatrix.mValueC+"\r"+imatrix.mValueD+"\r"+imatrix.mValueTX+"\r"+imatrix.mValueTY);
          if (imatrix.mValueA !=1 || imatrix.mValueB !=0)
              alert('rotated');
          else
              alert('unrotated');
          
          • 2. Re: finding the matrix info on a text frame?
            DuanesSearchForKnowledge Level 1

            Thanks Carlos!!!

             

            Hey Carlos, what does the $ mean?

            • 3. Re: finding the matrix info on a text frame?
              DuanesSearchForKnowledge Level 1

              Awesome Carlos!

               

              This deselects all angle text in my selection.

               

              /*------------------------------------------------------------------------------

                  Deselects all angle text from selection

              -------------------------------------------------------------------------------*/

              function deselectAllAngleTextFromSelection() {

                  var mydoc = app.activeDocument;

                  var mytext = idoc.textFrames;

                      for (i =0; i < mytext.length; i++) {

                              var mytextFrames = mydoc.textFrames[i];

                              var theMatrix = mytextFrames.matrix;

                              $.writeln(theMatrix.mValueA+"\r"+theMatrix.mValueB+"\r"+theMatrix.mValueC+"\r"+theMatrix. mValueD+"\r"+theMatrix.mValueTX+"\r"+theMatrix.mValueTY);

                                  if (theMatrix.mValueA !=1 || theMatrix.mValueB !=0) {

                                      mytextFrames.selected = false;

                                  }          

                      }

              }

               

              deselectAllAngleTextFromSelection();

               

              Thanks much,

              Duane

              • 4. Re: finding the matrix info on a text frame?
                CarlosCanto Adobe Community Professional & MVP

                Hi Duane, from the Guide

                 

                Dollar ($) object

                This global ExtendScript object provides a number of debugging facilities and informational methods. The

                properties of the $ object allow you to get global information such as the most recent run-time error, and

                set flags that control debugging and localization behavior. The methods allow you to output text to the

                JavaScript Console during script execution, control execution and other ExtendScript behavior

                programmatically, and gather statistics on object use.

                 

                 

                $.writeln use is similar to "alert" but instead of showing what you want in a "window" it writes the results to the estk console...check the Tools Guide, page 216.

                 

                if the estk is closed the script will open it to write to the console, so comment that line to avoid that.