7 Replies Latest reply on Mar 25, 2013 5:10 AM by BEGINNER_X

    Preserve Manual Overrides

    BEGINNER_X Level 3

      Hi All,

       

      I have a script which find  all the paragraph styles in myFind Array and change all the paragraph styles as per in the name of myChange Array.

       

      Request:

       

      Changing Paragraphs Styles without clear overrides or preserve local overrides like manual bold, italic etc....

       

       

      script:

       

      var myFind = ["H1", "H2", "H5"]

       

      var myChange = ["a_H1", "a_H2", "a_H5"]

       

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

       

           app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

           app.findGrepPreferences.appliedParagraphStyle = myFind[i];

           app.changeGrepPreferences.appliedParagraphStyle =myChange[i];

           app.activeDocument.changeGrep();

           app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

           }

       

      Could anyone give solution for preserve clear overrides.

       

       

      Thanks in advance

      Beginner

        • 1. Re: Preserve Manual Overrides
          Trevorׅ Adobe Community Professional

          As far as I know you can't use changeGrep to do it but you can use find grep and then loop through the finds and do

          myFinds[l].applyParagraphStyle (app.activeDocument.paragraphStyles.itemByName(myChange[i]),false)

          1 person found this helpful
          • 2. Re: Preserve Manual Overrides
            Jump_Over Level 5

            Hi,

             

            mFound = app.activeDocument.changeGrep();

            You need to go back into mFound array and use .clearOverrides() method with each element

             

            Jarek

            • 3. Re: Preserve Manual Overrides
              Trevorׅ Adobe Community Professional

              Hi Jarek,

               

              I think x wants to  preserve the local format and not clear the local overrides.

              The English there is not too clear to say the least.

               

              Either way the changeGrep() would clear the local formating without using clearOverrides(), which I think was the source of his problem

               

              Regards

               

              Trevor

              • 4. Re: Preserve Manual Overrides
                BEGINNER_X Level 3

                Dear Trevor/Jump_Over,

                 

                I want to preserve locat format (i.e., maintain manual bold, italic etc...)

                 

                 

                Trying Trevor script. But please find the screenshot

                 

                 

                 

                var myFind = ["H1", "H2"]

                 

                var myChange = ["a_H1", "a_H2"]

                 

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

                 

                     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

                 

                     app.findGrepPreferences.appliedParagraphStyle = myFind[i];

                 

                      myFind[i].applyParagraphStyle(app.activeDocument.paragraphStyles.itemByName(myChange[i]), false)

                 

                 

                //~      //app.changeGrepPreferences.appliedParagraphStyle =myChange[i];

                 

                //~      //app.activeDocument.changeGrep();

                 

                     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

                 

                     }

                 

                 

                Screen Shot 2013-03-25 at 12.07.33 PM.png

                • 5. Re: Preserve Manual Overrides
                  Jump_Over Level 5

                  Hi Trevor,

                   

                  Agree. To read english clearly is even more important

                   

                  Jarek

                  • 6. Re: Preserve Manual Overrides
                    BEGINNER_X Level 3

                    Hi Trevor/Jump_Over,

                     

                    Sorry for my bad English.....

                     

                    Could anyone give solution for my above request.

                    • 7. Re: Preserve Manual Overrides
                      Jump_Over Level 5

                      Hi, X

                       

                      As Trevor suggested use myFinds array.

                      myFinds = app.activeDocument.findGrep();

                       

                      You used myFind which is an array with paraStyles in fact.

                       

                      Jarek

                       

                      PS. No problem X, it was about my english, not yours (hopefully no problem too )

                       

                      Message was edited by: Jump_Over

                      • 8. Re: Preserve Manual Overrides
                        BEGINNER_X Level 3

                        Hi Jump_Over/Trevor,

                         

                         

                        With the help of yours, I got the solution. Thank you so much...

                         

                         

                        var myFind = ["H1", "H2"]

                         

                        var myChange = ["a_H1", "a_H2"]

                         

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

                         

                        var doc = app.activeDocument;

                             app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

                             app.findGrepPreferences.appliedParagraphStyle = myFind[i];

                        //~           myFinds = app.selection[0].findGrep();

                                            myFinds = app.selection[0].parentStory.findGrep();

                         

                             for(j=0; j<myFinds.length; j++)

                             {

                              myFinds[j].applyParagraphStyle(app.activeDocument.paragraphStyles.itemByName(myChange[i]) ,false)

                             app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

                             }

                        }

                         

                        Once Again Thank you so much Legends.....

                         

                         

                         

                        Regards

                        Beginner_X