7 Replies Latest reply on Apr 2, 2011 11:16 AM by Cris Ider

    Help me with this Script

    Cris Ider Level 1

      Please,

       

      How can I make this script working in Select Type Tool or Selection Tool mode

       

      It´s working just when I select by Selection Tool. I need it works Type Tool also.

       

       

      var mySel = app.selection[0];
      mySel.rotationAngle = 30;
      if(app.selection[0].hasOwnProperty("textFramePreferences"))  app.selection[0].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
      if(mySel instanceof TextFrame){
          with(mySel){
              texts[0].clearOverrides()
      }
      }

       

      This script Rotate my text 30º, Vertical Justification Center Align and finally clear overrides.

       

      Thanks!

        • 1. Re: Help me with this Script
          Mayhem SWE Level 2
          var mySel = app.selection[0].hasOwnProperty('parentTextFrames') ? app.selection[0].parentTextFrames[0] : app.selection[0];
          1 person found this helpful
          • 2. Re: Help me with this Script
            Cris Ider Level 1

            Thank you very much!!!!

            • 3. Re: Help me with this Script
              Cris Ider Level 1

              Hi, again!

               

              Sorry for my ignorance and another question.

               

              I´m trying add a function in my script, Fit Frame to Content (Fit frame to text), but it´s not working.

               

              var mySel = app.selection[0];
              mySel.rotationAngle = 30;
              if(app.selection[0].hasOwnProperty("textFramePreferences"))  app.selection[0].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
              if(mySel instanceof TextFrame){
                  with(mySel){
                      texts[0].clearOverrides()
              }
              }

              myFrame.fit(FitOptions.frameToContent);

               

               

               

               

              I think I have to define it. But I don´t know how do it.

               

              Can you help me?

              • 4. Re: Help me with this Script
                csm_phil Level 4

                Hi,

                 

                you can change the line this:

                mySel.fit(FitOptions.FRAME_TO_CONTENT);

                 

                 

                 

                thx,

                csm_phil

                • 5. Re: Help me with this Script
                  Cris Ider Level 1

                  Ok!

                   

                  Some functions work depending the mode of selection (Type Tool or Seleciont Tool)

                   

                  I Add app.seletion[0].appliedParagraphStyle = "CréditoFoto";

                   

                  // Paragraph Style created of course.

                   

                  See:

                   

                  var mySel = app.selection[0].hasOwnProperty('parentTextFrames') ? app.selection[0].parentTextFrames[0] : app.selection[0];
                  mySel.rotationAngle = 90;
                  if(app.selection[0].hasOwnProperty("textFramePreferences"))  app.selection[0].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
                  if(mySel instanceof TextFrame){
                      with(mySel){
                          texts[0].clearOverrides()
                  }
                  }
                  mySel.fit(FitOptions.FRAME_TO_CONTENT);
                  app.selection[0].appliedParagraphStyle = "CréditoFoto";

                   

                  Script.JPG

                  • 6. Re: Help me with this Script
                    csm_phil Level 4

                    Hi Cris,

                     

                    i have modified the your above js code; try this one

                     

                     

                    var mySel = app.selection[0];
                    mySel.rotationAngle = 90;
                    if(app.selection[0].hasOwnProperty("textFramePreferences")) 
                    app.selection[0].textFramePreferences.verticalJustification = VerticalJustification.CENTER_ALIGN;
                    if(mySel instanceof TextFrame){
                        with(mySel){
                            texts[0].clearOverrides()
                            }
                        }
                    app.selection[0].parentStory.paragraphs.everyItem().appliedParagraphStyle = "CréditoFoto";
                    mySel.fit(FitOptions.FRAME_TO_CONTENT);

                     

                    thx,

                    csm_phil

                    • 7. Re: Help me with this Script
                      Cris Ider Level 1

                      Thanks for your changes!

                       

                      The script worked by Selection Tool. I will try find a way to make it work with type tool also. It´s so hard to me.

                       

                      Thank you very much