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

Change leading value

Participant ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

Hi,

I have some paragraphs with overrides applied manually across the document.

I want to apply the leading that are in each respective paragraph styles without do the clearOverrides method because I have italic or colored words with no char style applied that I don't want to "clear".

Thank you in advance.

TOPICS
Scripting

Views

1.2K

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

People's Champ , Jul 31, 2017 Jul 31, 2017

You can use everyItem() in a collection purpose but you would still need to introspect every single paragraph as they may have different leading values.

var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

var n = myParas.length;

while ( n-- ) {

myParas.leading = myParas.appliedParagraphStyle.leading;

}

Votes

Translate

Translate
People's Champ ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

myPara.leading = myPara.appliedParagraphStyle.leading;

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 ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

And the var myPara would be? I tried app.activeDocument.stories.everyItem but not work.

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
People's Champ ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

You can use everyItem() in a collection purpose but you would still need to introspect every single paragraph as they may have different leading values.

var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

var n = myParas.length;

while ( n-- ) {

myParas.leading = myParas.appliedParagraphStyle.leading;

}

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 ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

Works!

Yeah I forgot to say that are various paragraph styles with different leadings. Sorry...

Thank you!

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 ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

Hi! I'm back!

I'm trying to apply this method only in a selected group with various elements, even other groups, include text frames that where my paragraphs are using selection[0] but I saw that this is not the way. I don't want to ungroup...

How I can achieve this?

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
People's Champ ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

Given that app.selection[0] is your group you need to introspect allPageItems property which is an array. If the nth item is of kind TextFrame you can then apply paragraphs changes.

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 ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

I see that's the way, but I don't know how to put this theory in the code. I'm a novice in javascript with indesign.

Can you help with the code? Sorry to bother you again

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 ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

I tried this, but nothing...

var mySel = app.selection[0];

var myEveryGroup = mySel.groups.everyItem().allPageItems;

var myParas = myDoc.stories.everyItem().paragraphs.everyItem().getElements();

for(var i = 0; i < myEveryGroup.length; i++) 

        for (var j = 0; j < myEveryGroup.length; j++) 

        { 

                myEveryGroup instanceof TextFrame && myEveryGroup.paragraphs.properties = {leading: myParas.appliedParagraphStyle.leading}; 

            } 

}

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 ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

I did it:

var mySel = app.selection[0];

var myEveryGroup = mySel.groups.everyItem().allPageItems;

for(var i = 0; i < myEveryGroup.length; i++) 

        for (var j = 0; j < myEveryGroup.length; j++) 

        { 

                myEveryGroup instanceof TextFrame && myEveryGroup.paragraphs.everyItem().leading = 14; 

            } 

}

To change the leading to a specific number, but don't know how to do with "appliedParagraphStyle" method.

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 ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Any light [Jongware]​ ? I mentioned you because maybe Loic.Aigon is busy.

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
Engaged ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hi,

var myGroup = app.selection[0]; 
 
// Building an array: 
var myGroupItems = myGroup.pageItems.everyItem().getElements();   
myGroup.ungroup(); 
// If you like a selection of the ungrouped items: 
app.select(myGroupItems);
var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();
var n = myParas.length;
while ( n-- ) {
myParas.leading = myParas.appliedParagraphStyle.leading;
}
myObj = app.selection; 
app.activeWindow.activePage.groups.add(myObj);

Thanks

Thanks
AP

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
Community Expert ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

Ribnog  wrote

I did it:

var mySel = app.selection[0];

var myEveryGroup = mySel.groups.everyItem().allPageItems;

for(var i = 0; i < myEveryGroup.length; i++) 

        for (var j = 0; j < myEveryGroup.length; j++) 

        { 

                myEveryGroup instanceof TextFrame && myEveryGroup.paragraphs.everyItem().leading = 14; 

            } 

}

To change the leading to a specific number, but don't know how to do with "appliedParagraphStyle" method.

Hi,

if you are after all items stored in app.selection[0] (I suppose a group of items of unknown depth with a nested structure) just get them like that:

var arrayOfPageItems = app.selection[0].allPageItems;

Then loop the items for text frames. Something like that:

var arrayOfPageItems = app.selection[0].allPageItems;

for(var n=0;n<arrayOfPageItems.length;n++)

{

    if(arrayOfPageItems.getElements()[0].constructor.name != "TextFrame"){continue};

    arrayOfPageItems.parentStory.texts[0].leading = 14;

};

Hope, that helps…

What I did not understand:
What do you mean by "how to do with "appliedParagraphStyle" method"?

Would you like to apply the new leading value only to paragraphs, that are formatted with a distinct paragraph style?

And if yes, would you like to have a locale override with leading? If not, just change the paragraph style…

Uwe

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 ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

LATEST

Hi Laubender​

I need to use the script in groups that I have to increase the size to 200%, so when I do that the text increases too. So to not have to ungroup them and apply your styles with your correct leading and pointSize (yes, I will need to change the size of the text too) I will need this.

So the appliedParagraphStyle is because in those groups I have text frames with differents text sizes and leadings and all of them have your own style so to not change one by one I think is more easy apply your respective styles to back to your right properties.

I think override.ALL works, but if some text have italic will miss it.

I hope you understand, my english is not very good.

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