8 Replies Latest reply on Oct 1, 2014 12:08 AM by seb400

    FindChangeByList script to include Style Groups/sub Style Groups

    seb400 Level 1

      I've been using this function happily (with varying degrees of success & lots of trial and error) for a while now. I'm not a script writer, understand very little but manage to copy and paste, and hope for the best.

       

      This has served my wishes for the most part, but I have the need to apply a GREP search/replace to some text that needs to be styled with a paragraph style that lives inside a style group, inside another style group.


      Style group called 'Headings', inside which is a style group called 'News from Areas heads' inside which is a paragraph style called 'b head_red (News from areas)'

       

      I have picked up on helpful examples from others for applying a paragraph style that lives within one level of "Style Group", but don't know what the correct syntax to describe: a paragraph style within a folder, within a folder, within another folder might be?


      I did wonder if the choice of underscores and brackets in the paragraph style may not help.

       

      MTIA

       

      Steve

        • 1. Re: FindChangeByList script to include Style Groups/sub Style Groups
          Jump_Over Level 5

          Hi,

           

          Only 1-level paragraphs' styles can be assigned using its name (string) as parameter.

          In case of groups you have to assing it as an object - so some basic javascript knowledge is needed, indeed.

           

          Find a logic here:

          If your style (say "mStyle") is located in group (say "groupTwo") which is inside a group (say "groupOne") ==> try to use a syntax:

           

          {appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("groupOne").paragraphStyleGroups.item("groupTwo").paragraphStyles.item("mStyle")}


          (I mean a text after 2nd tabulator in your FindChangeList.txt)


          Jarek

          • 2. Re: FindChangeByList script to include Style Groups/sub Style Groups
            seb400 Level 1

            Hi Jarek, thanks - that was my first guess (which I think I tried correctly, without success).

             

            I've copied and pasted your suggestion below, (with my parameters) - I get no response at all when I run FindChangeByList.jsx

             

            grep {findWhat:"(^(AREA)(.+)\\r)"} {changeTo:"$1", appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("Headings").paragraphSt yleGroups.item("News from Areas heads").paragraphStyles.item("b head_red (News from areas)")}

             

            I should have mentioned that I'm running CS6. I remember 'FindChangeByList.jsx' being available for CS3 would that be an issue?

             

             

            Steve

            • 3. Re: FindChangeByList script to include Style Groups/sub Style Groups
              Jump_Over Level 5

              Hi,

               

              1. What is your paraStyle real name? "b head_red (News from areas)" or "b head_red"?

              2. Do your findWhat string work in UI (run manually)?

              3. Do your FindChangeByList.jsx work with some simplier example? (just changeTo property)

               

              Jarek

              • 4. Re: FindChangeByList script to include Style Groups/sub Style Groups
                seb400 Level 1

                Hi Jarek

                 

                Unfortunately I don't have much scripting knowledge, but to answer your questions

                 

                1. paraStyle real name is "b head_red (News from areas)"

                    - "b head_red" is used elsewhere. Why didn't I keep it simple?

                2. Do your findWhat string work in UI (run manually)?

                    - yes, when I use normal GREP find/change it works okay.

                3. Do your FindChangeByList.jsx work with some simplier example?

                    - yes, I use it often. The .txt file I'm working on at the moment already contains about 10 text/glyph changes which work fine. I have had success in applying a 'paragraph style' that is within a 'style group'. But this is the first time I've tried to apply a 'paragraph style' that is in a 'style group', within a 'style group'.

                 

                Steve

                • 5. Re: Re: FindChangeByList script to include Style Groups/sub Style Groups
                  Jump_Over Level 5

                  Hi,

                   

                  If you run this line in ESTK what result can you see in console?

                   

                  app.activeDocument.paragraphStyleGroups.item("Headings").paragraphStyleGroups.item("News from Areas heads").paragraphStyles.item("b head_red (News from areas)").isValid
                  


                  true or false?


                  Jarek

                  • 6. Re: Re: FindChangeByList script to include Style Groups/sub Style Groups
                    seb400 Level 1

                    Hi Jarek

                     

                    I'm very sorry for the two week delay in replying to your last message.

                    Work has been frantic and I've been tied up on other things.

                     

                    Assuming that I've manage to follow what you asked me to do correctly (I copied your line of text into the 'Source1' panel of the javascript console and clicked the green arrow). There is a message at the bottom left of the window saying "undefined is not an object".

                    • 7. Re: Re: Re: FindChangeByList script to include Style Groups/sub Style Groups
                      Jump_Over Level 5

                      Hi,

                       

                      What about the line:

                      app.activeDocument.paragraphStyleGroups.item("Headings").paragraphStyleGroups.item("News from Areas heads").paragraphStyles.item("b head_red").isValid 
                      

                       

                      I general ==> use the group's and style's names as you can see them in a UI Style Panel

                       

                      Jarek

                      • 8. Re: FindChangeByList script to include Style Groups/sub Style Groups
                        seb400 Level 1

                        Hi Jarek

                         

                        no joy with that either. Although as usual, I have accidentally stumbled across a method that works (which is entirely logical, as usual!)

                         

                        appliedParagraphStyle: app.activeDocument.paragraphStyleGroups.item("Headings").paragraphStyleGroups.item("News from Areas heads").paragraphStyles.item("b head_red (News from areas)")

                         

                        just repeating the 'Style groups' command, with the nested folders name!

                         

                        Haven't yet tested it on all the instances I need yet!

                         

                        Many thanks for your help

                         

                        steve