2 Replies Latest reply on Jul 26, 2014 10:27 AM by Teetan VK

    Change script function, can you?

    Teetan VK Level 1

      Hi everyone

       

      I got this script,

       

      function: change font size in selection

       

      but I want to change the function to selection text frames

       

      I mean: change the font size in all the selected text frames.

       

      thanks

       

      //---------------------------------------------------------------------------------------- -----------------------

       

       

      var the_document = app.documents.item(0);

      var the_selection = app.selection[0];

       

      var the_dialog = app.dialogs.add({name:"Resize selected text"});

      with(the_dialog.dialogColumns.add()){

          with(dialogRows.add()){

              staticTexts.add({staticLabel:"Resize the selected text by"});

              var increase_by = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:0});

          }

      }

      the_dialog.show();

       

      counter = 0;

      do {

          var current_character = the_selection.characters.item(counter);

         

          current_character.pointSize = current_character.pointSize + increase_by.editValue;

          counter++;

      } while (counter < the_selection.characters.length);

       

      alert("Done!");

       

      //---------------------------------------------------------------------------------------- ------------------------

       

      VK

        • 1. Re: Change script function, can you?
          Kai Rübsamen Adobe Community Professional

          Try the following:

           

          var sel = app.selection;
          if (sel.length == 0 ) {
              alert ( "Nothing selected" ); exit();
          }
          
          var dlg = app.dialogs.add({ name: "Resize text in selected frames" });
          dlg.dialogColumns.add().staticTexts.add({ staticLabel: "Resize the selected text by:" });
          var increase_by = dlg.dialogColumns.add().measurementEditboxes.add({ editUnits:MeasurementUnits.POINTS, editValue: 0 });
          
          if (dlg.show()) {
              var dlg_value = increase_by.editValue;
              dlg.destroy();
          }
          else {
              dlg.destroy(); exit();
          }
          
          for ( var i = 0; i < sel.length; i++ ) {
              var curSel = sel[i];
              if ( curSel.constructor.name == "TextFrame" ) {
                  var tsr = curSel.parentStory.textStyleRanges;
                  for ( var n = 0; n < tsr.length; n++ ) {
                      var curTsr = tsr[n];
                      curTsr.pointSize += dlg_value;
                  } // for
              } // if
          } // for
          
          alert( "Done!" );
          

           

          –Kai

          • 2. Re: Change script function, can you?
            Teetan VK Level 1

            Hi Kai

             

            Thank you so much!

             

            VK