3 Replies Latest reply on Dec 13, 2010 1:17 PM by chughes133

    Make a script function as a single action rather than many

    chughes133

      Basically I have a loop that changes all the paragraph and character styles in a document for a particular language.


      As such however, every time someone runs it, if you need to undo you have to hold down ctrl+z for a while. I'd rather if it ran a bit cleaner in this regard.

       

      Here is the script, please let me know what I need to wrap it in in order to do this. Also, I'm running cs4, however I'd like it to be scalable for cs3 and cs5 as well, as currently it already does. All the best

      /c

       

      function arabic()
          {
          var myStyles = app.activeDocument.allParagraphStyles;
          var myChStyles = app.activeDocument.allCharacterStyles;
      //Paragraph Styles       
              for (oneStyle=1;oneStyle<myStyles.length;oneStyle++)
                  {
                  myStyles[oneStyle].appliedLanguage= "Arabic";
                  myStyles[oneStyle].ligatures= true;
                  myStyles[oneStyle].hyphenation= true;
                  myStyles[oneStyle].kerningMethod= "Metrics";
                  myStyles[oneStyle].justification= 1919578996;
                  myStyles[oneStyle].paragraphDirection= 1379028068;
                  myStyles[oneStyle].paragraphJustification= 1886023265;
                  myStyles[oneStyle].digitsType= 1684629609;
                  myStyles[oneStyle].characterDirection= 1379028068;
                  myStyles[oneStyle].composer= "Adobe World-Ready Paragraph Composer";
         //Pointsize, basic model
                  var myPoint = myStyles[oneStyle].pointSize;
                  myStyles[oneStyle].pointSize= myPoint + 3;
         //Leading, basic model
                  var myLead = myStyles[oneStyle].leading;
                  if (myStyles[oneStyle].leading == 1635019116){
                      myStyles[oneStyle].leading = 1635019116;}
                  else myStyles[oneStyle].leading = myLead + 3;
         //FONT CONDITIONALS
         //Garamond Pro
                  if (myStyles[oneStyle].appliedFont.fontFamily== "Adobe Garamond Pro"){
                      myStyles[oneStyle].appliedFont= "Traditional Arabic";
                      if (myStyles[oneStyle].fontStyle== "Roman"){
                          myStyles[oneStyle].fontStyle= "Regular";}
                      else if (myStyles[oneStyle].fontStyle== "Italic"){
                          myStyles[oneStyle].fontStyle= "Regular";
                          myStyles[oneStyle].skew= -15;}
                      else if (myStyles[oneStyle].fontStyle== "Semibold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Semibold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";
                          myStyles[oneStyle].skew= -15;}
                      else if (myStyles[oneStyle].fontStyle== "Bold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Bold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";
                          myStyles[oneStyle].skew= -15;}}
         //Minion Pro
                  else if (myStyles[oneStyle].appliedFont.fontFamily== "Minion Pro"){
                      myStyles[oneStyle].appliedFont= "Traditional Arabic";
                      if (myStyles[oneStyle].fontStyle== "Regular"){
                          myStyles[oneStyle].fontStyle= "Regular";}
                      else if (myStyles[oneStyle].fontStyle== "Italic"){
                          myStyles[oneStyle].fontStyle= "Regular";
                          myStyles[oneStyle].skew= -15;}
                      else if (myStyles[oneStyle].fontStyle== "Semibold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Semibold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";
                          myStyles[oneStyle].skew= -15;}
                      else if (myStyles[oneStyle].fontStyle== "Bold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Bold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";
                          myStyles[oneStyle].skew= -15;}}
         //Myriad Pro
                  else if (myStyles[oneStyle].appliedFont.fontFamily== "Myriad Pro"){
                      myStyles[oneStyle].appliedFont= "Yakout Linotype";
                      if (myStyles[oneStyle].fontStyle== "Regular"){
                          myStyles[oneStyle].fontStyle= "Light";}
                      else if (myStyles[oneStyle].fontStyle== "Italic"){
                          myStyles[oneStyle].fontStyle= "Light";
                          myStyles[oneStyle].skew= -15;}
                      else if (myStyles[oneStyle].fontStyle== "Semibold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Semibold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Bold"){
                          myStyles[oneStyle].fontStyle= "Bold";}
                      else if (myStyles[oneStyle].fontStyle== "Bold Italic"){
                          myStyles[oneStyle].fontStyle= "Bold";
                          myStyles[oneStyle].skew= -15;}}
                  }
      //Character styles
              for (unStyle=1;unStyle<myChStyles.length;unStyle++)
                  {
                  myChStyles[unStyle].appliedLanguage= "Arabic";
                  if (myChStyles[unStyle].fontStyle== "Italic"){
                      myChStyles[unStyle].fontStyle= NothingEnum.nothing;
                      myChStyles[unStyle].skew= -15;}   
                  }
          }
      arabic();