-
1. Re: Creating a Style List
TᴀW Nov 7, 2011 8:56 AM (in response to Eugene Tyson)Which style do you want to apply to the text in the list? (Using email
and can't see the picture)
Ariel
-
2. Re: Creating a Style List
TᴀW Nov 7, 2011 8:58 AM (in response to Eugene Tyson)Also, is it a list of paragraph styles that you want?
Plus, how do you want the script to deal with style groups?
Ariel
-
3. Re: Creating a Style List
Eugene Tyson Nov 7, 2011 9:07 AM (in response to Eugene Tyson)Just to list them out in the order they are in. From top to bottom.
Basically, the text should read the Style name, then apply that style to the text.
Heading 1
Heading 2
Heading 3
Body Text
Body Text Indent
and so on
-
4. Re: Creating a Style List
TᴀW Nov 7, 2011 10:22 AM (in response to Eugene Tyson)1 person found this helpfulI'm ignoring groups, and presuming we're on CS4 (and possibly upwards)
and that you've got your text cursor in an empty text frame, and I
haven't tested this much because I'm right in the middle of something,
but here goes:
myDoc = app.activeDocument;
myStyles = myDoc.allParagraphStyles;
myStory = app.selection[0].parentStory;
for (a=0; a<myStyles.length; a++){
myStory.insertionPoints[-1].contents = myStyles[a].name+"\r";
myStory.paragraphs[-1].appliedParagraphStyle = myStyles[a];
}
Does that help?
Ariel
-
5. Re: Creating a Style List
Liphou Nov 7, 2011 1:51 PM (in response to Eugene Tyson)1 person found this helpfulList of style carataires.
List of paragraph style and its réapliqué
For me it works, the code needs to be improved ...
Attention to the character in the names of styles (no (), ° §) it poses problemsTranslation of French
Liste des style de carataires.
Liste des style de paragraphes et il son réapliqué
Pour moi ça marche, le code demande à être amélioré ...
Attention au caractère dans le nom des styles ( pas de (), °, §) sa pose des problème
var leNombreDeGroupeCara = app.activeDocument.characterStyleGroups.length; // conteur de groupr de style para
var lesStyleDocCara = [];
lesStyleDocCara = styleDocCar();
if (leNombreDeGroupeCara != 0 ) {
for (i = 0; i < leNombreDeGroupeCara; i++) { // for 01
var conteurStyle = app.activeDocument.characterStyleGroups[i].characterStyles.length;
for (y = 0; y < conteurStyle; y++) { // for 02
lesStyleDocCara.push(app.activeDocument.characterStyleGroups[i].characterStyles[y].name);
} // for 02
} // fin du FOR 01
} else {
alert(leNombreDeGroupeCara);
} // fin du IF
var leNombreDeGroupePara = app.activeDocument.paragraphStyleGroups.length; // conteur de groupr de style para
var lesStyleDoc = [];
lesStyleDoc = styleDocPara();
if (leNombreDeGroupePara != 0 ) {
for (i = 0; i < leNombreDeGroupePara; i++) { // for 01
var conteurStyle = app.activeDocument.paragraphStyleGroups[i].paragraphStyles.length;
for (y = 0; y < conteurStyle; y++) { // for 02
lesStyleDoc.push(app.activeDocument.paragraphStyleGroups[i].paragraphStyles[y].name);
} // for 02
} // fin du FOR 01
} else {
alert(leNombreDeGroupePara);
//$.writeln (leNombreDeGroupePara);
} // fin du IF
myDoc = app.activeDocument;
myStory = app.selection[0].parentStory;
myStory.insertionPoints[-1].contents = "Style Cara\r";
for (a=0; a<lesStyleDocCara.length; a++){
myStory.insertionPoints[-1].contents = lesStyleDocCara[a]+"\r";
}
myStory.insertionPoints[-1].contents = "Style Para\r";
for (a=1; a<lesStyleDoc.length; a++){
myStory.insertionPoints[-1].contents = lesStyleDoc[a]+"\r";
if (app.activeDocument.paragraphStyles.item(lesStyleDoc[a])){
try{
myStory.paragraphs[-1].appliedParagraphStyle = app.activeDocument.paragraphStyles.item(lesStyleDoc[a]);
}
catch (e){
var leStyle = lesStyleDoc[a];
myStory.paragraphs[-1].appliedParagraphStyle = app.activeDocument.paragraphStyleGroups[0].paragraphStyles.item(leStyle);
}
}
} //
function styleDocCar() {
var variableLocal = app.activeDocument.characterStyles.everyItem().name.join("|");
return variableLocal.split("|");
}// fin de
function styleDocPara() {
var variableLocal = app.activeDocument.paragraphStyles.everyItem().name.join("|");
return variableLocal.split("|");
}// fin de
-
6. Re: Creating a Style List
Liphou Nov 7, 2011 2:12 PM (in response to Eugene Tyson)Hi
I have treated one group of style, there should be a routine test in all the group!
Translation Frabçais
je n'ai traité qu'un seul groupe de style, il faudrais faire une routine qui test dans tous les groupe!
Philou
-
7. Re: Creating a Style List
[Jongware] Nov 7, 2011 2:24 PM (in response to Eugene Tyson)Short & sweet. Wasn't there a post on InDesignSecrets, by the way, doing the same? (Can't be bothered to look it up because this is way more fun.)
if (app.documents.length > 0 && app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline")) for (p=2; p<app.activeDocument.allParagraphStyles.length; p++) { name = app.activeDocument.allParagraphStyles[p].name; par = app.activeDocument.allParagraphStyles[p].parent; while (par instanceof ParagraphStyleGroup) name = par.name+" : "+name, par = par.parent; app.selection[0].parentStory.insertionPoints[-1].properties = {contents:name+"\r", appliedParagraphStyle:app.activeDocument.allParagraphStyles[p]}; }
-
8. Re: Creating a Style List
Eugene Tyson Nov 8, 2011 1:21 AM (in response to Eugene Tyson)Thanks everyone. I liked Jongware's version it was a lot shorter and did exactly what I wanted.
Thanks everyone
-
9. Re: Creating a Style List
Maria964 Nov 8, 2011 5:06 AM (in response to Eugene Tyson)I Jongware,
This one is a very useful script for me and I supose for a lot of people. But it whould be better if it executes only with the paragrah styles that are inside a Style Group. Can you do this for me?
Thank you in advance
Maria
-
10. Re: Creating a Style List
[Jongware] Nov 8, 2011 5:51 AM (in response to Maria964)Yeah sure.
if (app.documents.length > 0 && app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline")) for (p=2; p<app.activeDocument.allParagraphStyles.length; p++) { if (app.activeDocument.allParagraphStyles[p].parent instanceof ParagraphStyleGroup) { name = app.activeDocument.allParagraphStyles[p].name; par = app.activeDocument.allParagraphStyles[p].parent; while (par instanceof ParagraphStyleGroup) name = par.name+" : "+name, par = par.parent; app.selection[0].parentStory.insertionPoints[-1].properties = {contents:name+"\r", appliedParagraphStyle:app.activeDocument.allParagraphStyles[p]}; } }
-
11. Re: Creating a Style List
Laubender Nov 8, 2011 6:17 AM (in response to [Jongware])@Jongware:
Hm. Maybe it's better to set p=1 so we can catch the [Basic Paragraph] style.Uwe
-
12. Re: Creating a Style List
[Jongware] Nov 8, 2011 6:38 AM (in response to Laubender)I intentionally skipped it because your documents can catch some contagious stuff from it!
(Interested lurchers: I started with index #2 because
#0 is [No Paragraph Style]
#1 is [Basic Paragraph Style]
Including [No Paragraph Style] is useless, as it's always equal to [Basic]. [Basic] can be redefined and used; however, I think in general it's advised not to, because copying text with a Basic style or one based on it to a document with a different definition Will Mess You Up.)
-
13. Re: Creating a Style List
Eugene Tyson Nov 8, 2011 7:35 AM (in response to [Jongware])I'm glad you skipped the Basic Paragraph Style - it's not needed at all. It shouldn't even be in the program from the start.
-
-
15. Re: Creating a Style List
Maria964 Nov 8, 2011 9:23 AM (in response to [Jongware])Thank you very much
Maria
-
16. Re: Creating a Style List
Liphou Nov 8, 2011 9:32 AM (in response to Eugene Tyson)Congratulations class! [Jongware]
-
17. Re: Creating a Style List
BenCloutier Dec 7, 2011 6:51 AM (in response to [Jongware])Wow, always impressed! I added the Character style based on that script (changed all "Paragraph" to "Character" and "p=2" to "p=1")