• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help about Paragraph and character styles scriptting

Participant ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

Hello all,

i'm working on a large project with many files, i have to change edit on all Paragraph styles with multiple processes

for ex, change font for all Paragraph styles on all opened documents

          var docs = app.documents; 

                

          for (var d = docs.length-1; d >= 0; d--) { 

                  var doc=docs;

                 

var pstyles = doc.allParagraphStyles; 

for (var a = 1; a < pstyles.length; a++) {   

                          if (pstyles.appliedFont.name=="Arial\tBold")   

                               pstyles.appliedFont = "Arial\tBold Italic";   

                     }

                 }

but i found some text inside frames with (locked position) so my find/change didn't apply on it

so are there anyway to do this process to all locked position frame??

or at least do un lock to all opened documents but i only can do this for active doc

app.activeDocument.pageItems.everyItem().locked = false

another thing, i tried to edit on all Character styles on files and i wrote code with my little scripting knowledge but it seems not working, any hint please???

          var docs = app.documents; 

                

          for (var d = docs.length-1; d >= 0; d--) { 

                  var doc=docs;

                 

var cstyles = doc.allCharacterStyles; 

for (var a = 1; a < cstyles.length; a++) {   

                          if (cstyles.appliedFont.name=="Arial\tBold")   

                               cstyles.appliedFont = "Arial\tBold Italic"; 

                     }

}

         } 

Thanks in advance

TOPICS
Scripting

Views

639

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Sep 23, 2016 Sep 23, 2016

May be your text frame grouped.. try this

var docs = app.documents;    

for (var d = docs.length-1; d >= 0; d--) {    

var doc=docs

var pgItems = doc.allPageItems;

    for (var a = 0; a < pgItems.length; a++) {      

            if(pgItems instanceof TextFrame){

    while (doc.groups.length > 0)

    doc.groups.everyItem().ungroup();

  pgItems.locked = false;      }

}

}

Votes

Translate

Translate
People's Champ ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

I can't see any reason why you couldn't change the font associated with a paragraphStyle whatever some text which style is applied to is locked or not. Unles you do find/replace texts and that in this case if you deactivated the search on locked items, then you can have thos kind of behaviours. But tweaking the style should n't be an issue.

A possible issue is that the texts have overrided styles so the look isn't compliant with your expectations.

FWIW

Loic

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

Hi Loic,

actually i have many files to change fonts in all PS on it so i have to create a script can do multiple find/change fonts in all paragraph styles on all opened documents with (locked/unlocked) frames

i hope you got my point

Suzan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

use to unlocking all

app.menuActions.itemByID(11396).invoke();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

Hi tbk1982,

well your line works well to unlock all in active document only, i always face same problem can't re code any script to be applied on all opened documents

please any hint or help

BR

Suzan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

and btw what about my question for character styles, any hint for this code i posted?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 22, 2016 Sep 22, 2016

Copy link to clipboard

Copied

It works try this

var docs = app.documents;   

for (var d = docs.length-1; d >= 0; d--) {   

var doc=docs;  

var cstyles = doc.characterStyles;   

    for (var a = 0; a < cstyles.length; a++) {   

        if (cstyles.appliedFont=="Cambria" && cstyles.fontStyle =="Bold") { 

        cstyles.appliedFont = "Cambria"

        cstyles.fontStyle = "Bold Italic"       

        } 

    } 

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

to unlock text frames for all open documents.. use this

var docs = app.documents;   

for (var d = docs.length-1; d >= 0; d--) {   

var doc=docs;

var pgItems = doc.allPageItems;

    for (var a = 0; a < pgItems.length; a++) {     

            if(pgItems instanceof TextFrame){

            pgItems.locked = false;

            }

    }

}

Thanks,

K

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

Hi K,

sorry for bothering you again and again.

i got this error wid your code !!

014.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

May be your text frame grouped.. try this

var docs = app.documents;    

for (var d = docs.length-1; d >= 0; d--) {    

var doc=docs

var pgItems = doc.allPageItems;

    for (var a = 0; a < pgItems.length; a++) {      

            if(pgItems instanceof TextFrame){

    while (doc.groups.length > 0)

    doc.groups.everyItem().ungroup();

  pgItems.locked = false;      }

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

LATEST

again you saved my day

thanks a lot dear

BR,

Suzan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

tpk1982 wrote:

It works try this

  1. vardocs=app.documents;
  2. for(vard=docs.length-1;d>=0;d--){
  3. vardoc=docs;
  4. varcstyles=doc.characterStyles;
  5. for(vara=0;a<cstyles.length;a++){
  6. if(cstyles.appliedFont=="Cambria"&&cstyles.fontStyle=="Bold"){
  7. cstyles.appliedFont="Cambria"
  8. cstyles.fontStyle="BoldItalic"
  9. }
  10. }
  11. }

works great, i see now the difference with my code was the line

  1. var cstyles = doc.allCharacterStyles

thanks a lot dear

now only last issue about  locked frames

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines