2 Replies Latest reply on Dec 29, 2011 9:38 AM by Eugene Tyson

    Unlink based on styles from Basic styles

    Eugene Tyson Adobe Community Professional & MVP

      I seem to remember this from a while ago, but I can't find anything.

       

      If I move pages between documents and someone else has setup the style to be based on the Basic style, then sometimes the result is not what is expected.

       

      Say if I had

       

      Basic Paragraph Style

      Body

      H1

      H2

       

      and Body, H1, H2 are all Based on Basic Paragraph style.

       

      Then perhaps the script could unlink Body, H1, H2 to a duplicate of Basic Paragraph Style so it looks like

       

      Basic Paragraph Style

      Basic Style Copy

      Body

      H1

      H2

       

      where Body and H1 and H2 are now based on Basic Style Copy.

       

      Would anyone have:

      A better way?

      If a script already exists for this?

      Or if someone can write something that would work in unlinking all styles from the Basic Paragraph Styles?

        • 1. Re: Unlink based on styles from Basic styles
          absqua Level 4

          This will make a copy of [Basic Paragraph] and base any styles based on it on the duplicate. I don't really see a better way. I wish, if we have to live with [Basic Paragraph], there were a preference for what to do with conflicts when copying from another document.

           

          function main() {
              var doc = app.activeDocument,
                    basicStyle = doc.paragraphStyles.item("[Basic Paragraph]"),
                    newStyle = basicStyle.duplicate(),
                    i, l, style;
          
          
              for (i = 0, l = doc.allParagraphStyles.length; i < l; i++) {
                  style = doc.allParagraphStyles[i];
                  if (style.name !== "[No Paragraph Style]" && style.basedOn === basicStyle) {
                      style.basedOn = newStyle;
                  }
              }
          }
          
          if (app.documents.length > 0) {
              app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Base Paragraph Styles on Copy of [Basic Paragraph]");
          }
          

           

          Jeff

          • 2. Re: Unlink based on styles from Basic styles
            Eugene Tyson Adobe Community Professional & MVP

            Thanks that's great