2 Replies Latest reply on Mar 10, 2013 9:51 AM by shilpa25

    clear overrides  keep tracking as it is

    shilpa25 Level 1

      Hi Forum,

       

      (Im trying to apply character styles through script and maintain overrides).

       

      im  pasting contents from word into indesign between the paragraph, keeping "All Information (Index, swatches etc) ticked on" in Clipboard Handling in General Perferences Settings, to maintain bold and italics as is in the word document.

       

      Im replacing  the bold, italic - fontStyle applied in word doc, and applying  bold & italic character style created through Script.

       

      It seems that the fontFamily still remains unchanged and the paragraphStyle with overrides..

       

      I also cleared the overrides using.

       

      app.selection[0].clearOverrides();

       

      unfortunately it seems, that the manual "trackings applied to that paragraph is also resetted.

       

      How could i apply fontFamily of the pasted contents, without clearing overrides...

       

      var myDoc = app.activeDocument;

      if (myDoc.characterStyles.item("Bold") == null) {

      var myCharStyle = myDoc.characterStyles.add({name:"Bold"});

      }

      app.findTextPreferences.fontStyle = "Bold"

      app.changeTextPreferences.appliedCharacterStyle = "Bold"

      app.changeText();

      app.selection[0].clearOverrides();

       

      thanks & regards,

      Shil..

        • 1. Re: clear overrides  keep tracking as it is
          Jump_Over Level 5

          Hi,

           

          Let your "Bold" style be a bold:

          var myCharStyle = myDoc.characterStyles.add({name:"Bold", fontStyle: "Bold"});

           

          Notice that to define a characterStyle based on selected text doesn't mean to set text properties to a style. This kind of style is an "empty" definition - just a name.

          • 2. Re: clear overrides  keep tracking as it is
            shilpa25 Level 1

            hellow JumpOver,

             

            much thanks and appreciation to your advise. As you always try to correct me, when I am doing wrong.

             

            JumpOver,

            actually i have also metioned the FontStyle property; but i forgot to mention show in forum..

             

            var myDoc = app.activeDocument;

            if (myDoc.characterStyles.item("Bold") == null) {

                  var myCharStyle = myDoc.characterStyles.add({name:"Bold", fontStyle: "Bold"});

            }

            else {

                   var myCharStyle = myDoc.characterStyles.item("Bold");

            }

             

            app.findTextPreferences.fontStyle = "Bold"

            app.changeTextPreferences.appliedCharacterStyle = "Bold"

            app.changeText();

            myDoc = app.activeDocument;

            for (j = myDoc.stories.length - 1; j >= 0; j--) {

                myStory = myDoc.stories.item(j);

                myParas = myStory.paragraphs;

            //    if (myParas.length > 5) {

                    for (i = 0; i <myStory.paragraphs.length;  i++) {

             

                        if (myStory.paragraphs[i].appliedParagraphStyle.name == "Normal") {

            myStory.paragraphs[i].appliedParagraphStyle = myStory.paragraphs[i-1].appliedParagraphStyle;

            }}}

             

            because as i said, when i keep the setting,  "All Information (Index, swatches etc) ticked on" in Clipboard Handling in General Perferences, while i copy and paste, it will present inside the indesign as "normal style"..

             

            and so i replace with the paragraph [i-1].appliedParagraphStyle...

             

            but when i copy and paste in a same, paragraph, the bold is applied, but the fontFamily is not updated and it shows a difference inside the paragraph...

            and so i scripted..... at final as...

             

            app.selection[0].clearOverrides();

             

            because of this, if the paragraph is manually tracked, -5 pt.. the overset is released and turned back to 0pt... as a result of this,, i had to manually select and again set -5pt to the same paragraph....

             

            thanks jumpover_.....

             

            please see my next post forthe screen shot.... and sorry for the briefed story. tomake you clear, as i had made wrong to understand you...its my unclear posting.!.....

             

            thanks

            shil...