10 Replies Latest reply on May 15, 2017 11:54 PM by Abambo

    Is there already a script for showing style inheritance?

    Joel Cherney Adobe Community Professional & MVP

      Howdy scripting forum folks,

       

      I started playing around with ways to visually represent the entire set of styles in a given document, showing which styles are based on which other styles. However, I think that it's entirely beyond my JS abilities at the moment. Has anyone ever written a script that would show all of the styles in a tree format, so that it would be really easy to determine which style was the "root" style, and which values for a given child style would inherit from the parent?

       

      I only ask because the documents I typically recieve have no styling information, or styles constructed so poorly that it's faster for me to delete all the styles and remake them myself. However, one my clients must have hired a new designer, who actually has a clue and uses styles fairly well, but not perfectly. So, in order to figure out which styles inherit the font from above, and which ones have to be specified manually, I basically need to open up each one and note what it is based on, and how it is different from what it's based on. This is giving me some brand-new grey hairs, as I'm working in a doc with about 100 para styles. Surely, someone has already faced this and whipped together some sort of visual representation of inheritance in styles?

       

      If not... I'm going to have a lot of questions for you as I stumble through this with my rudimentary JS knowledge. TIA.

        • 1. Re: Is there already a script for showing style inheritance?
          Steven.. Level 3

          Harbs, don't you do that in your autofill pro plugin. You may have shared already too many secrets for 1 day.

           

          Steven

          http://scriptui.com

          • 2. Re: Is there already a script for showing style inheritance?
            [Jongware] Most Valuable Participant

            I thought of quickly writing a ScriptUI dialog for this -- a treeview could display the parental state. But it's by far not as easy as I thought

             

            Determining based-on styles is easy. A paragraph style has a 'basedOn' property, which is .. a paragraph style. The very last one in the chain has a basedOn property of 'null' (nothing). So, if you have a reference to a certain style, this will walk through the hierarchy:

             

            myParStyle = app.activeDocument.allParagraphStyles[2];

            while (myParStyle)

            {

               .. do something ..

               myParaStyle = myParaStyle.basedOn;
            }

             

            -- the loop should automatically stop on the first 'null'.

             

            Rather unfortunate again is that you cannot have ID list the changes from one style to another. You have to compare paragraph and character properties manually, i.e.,

             

            if (myParStyle.pointSize != myParStyle.basedOn.pointSize)

              alert ("The point size differs");

             

            -- and if you don't know in advance what properties might have been changed, you have to test all of them.    

            • 3. Re: Is there already a script for showing style inheritance?
              Harbs. Level 6

              Hi Steven,

               

              Yes I did.

               

              I'm actually in middle of doing an exercise to get better aquinted with Flex and PatchPanel. I'm woriking on a PatchPanel panel which will display styles in a based on structure and allow drag and drop to rearrange the structure. Right now it's very much on the back burner, but I'll finish it eventually... When I do, I plan to make it available for free download...

               

              For now, I just whipped together this script which shows the structure, although you can't do anything with other other than look...

               

              http://in-tools.com/indesign/scripts/freeware/ShowBasedOn.zip

               

              Harbs

              1 person found this helpful
              • 5. Re: Is there already a script for showing style inheritance?
                Harbs. Level 6

                Thanks, Peter

                 

                It was not much more than copying and pasting existing functions...

                 

                Here's what this looks like in AutoFlow Pro. These dialogs allow for switching between based on and style group views on the fly. It's a lot of fun to use (at least for me...)

                 

                AutoFlow_Pro_styles.jpg

                AutoFlow_Pro_master_links.jpg

                • 6. Re: Is there already a script for showing style inheritance?
                  Joel Cherney Adobe Community Professional & MVP

                  This is good stuff - many thanks! Your quick-and-dirty parent-identifier will come in very handy today, Harbs, although I think I wouldn't be able to make much use of Autoflow Pro outside of the ShowBasedOn functionality.

                   

                  I'd already imagined that comparing every single parent value against every single child value would be a huge pain, Jongware, but I guess that really is my dream. Because, you know, I'm doing it manually now. I would assume that squirting the entire list values in a para style into an array, doing the same for the child, and comparing the arrays and noting any differences would be (barely) within my capabilities. So, that would at least get me to a list of what I needed to change. How to script parastyle changes, and the UI for same, is beyond me right now, but I'll be diving into it this weekend.

                  • 7. Re: Is there already a script for showing style inheritance?
                    Harbs. Level 6

                    What? You don't think you can use AutoFlow Pro? You're bursting my bubble!

                    I was totally convinced that every single InDesign user on the planet would instantly run out and buy it!

                     

                    Well, maybe I didn't really think that, and that's why I wrote that script...

                     

                    As far as compring values, it shouldn't be that hard. You just loop through the props using "for(x in style)", and compare the two props agains each other. If they're different, you add the value to a list...

                     

                    Harbs

                    • 8. Re: Is there already a script for showing style inheritance?
                      Joel Cherney Adobe Community Professional & MVP

                      What? You don't think you can use AutoFlow Pro? You're bursting my bubble!

                      I was totally convinced that every single InDesign user on the planet would instantly run out and buy it!

                      Well, I don't really have the kind of job where I get to, you know, make stuff. I'm sure I'd use it all the time if I were actually building layouts myself. Mostly I just deal with other people's work - hence my question - and while the layouts I get are sometimes well-thought-out and a dream to work in, um, er, there's no nice way to finish that sentence.

                       

                      I did try, though.

                      • 9. Re: Is there already a script for showing style inheritance?
                        [Jongware] Most Valuable Participant

                        Holy smelly socks, Harbs. Your tree view looks exactly like what I had in mind.

                         

                        As far as compring values, it shouldn't be that hard. You just loop through the props using "for(x in style)", and compare the two props agains each other. If they're different, you add the value to a list...

                         

                        That easy, eh? .. (five minutes later:) Boyo, this works like a charm.

                         

                        f = app.layoutWindows[0].activePage.textFrames.add({geometricBounds:["12mm","12mm","80mm","80mm"]});
                        p = app.activeDocument.paragraphStyles.item("Caption");
                        for (x in p)
                          if (p[x] != p.basedOn[x])
                           f.insertionPoints[-1].contents = x+"\r"

                         

                         

                        It's a bit rough around the edges, but I think I can do several useful things with this.

                        • 10. Re: Is there already a script for showing style inheritance?
                          Abambo Level 4

                          This script is very useful. Thanks for creating such a jewel...