Since leading is not honored at the beginning of a frame, what is the problem?
Select a textframe, go to 'texts' and apply your leading value.
...to change the leading of all the text in a text-frame WITHOUT affecting the rest of the text of any paragraph that flows into a different frame...
Describe your goal deeper, pls --> cause to change leading MEANS to reflow followed text.
Are you going to break a chain or resize a frame or...?
My goal is as follows:
For pagination purposes I need, for example, to have 30 lines of text in a text-frame, but I only have room for 29, so I want to (through scripting) change the leading in THAT frame, without affecting any other frame.
First advice - use frame.verticalJustification
Still need to be explained - if 30th line need to be sucked in (from the next frame) so next frame is affected or not?
I would use the baseline grid of the text frame so that exactly 30 lines of text fit into the frame.
The text should be formatted to honor the baseline grid settings.
In my example above the text is: 7.5 pt size with 7.5 pt leading.
The grid in the selected text frame is set to 8 pt so that 30 lines would fit in.
All other text in the next frame will honor the baseline grid of the document.
If you change the formatting, add or remove some text, still 30 lines of text will go into the first frame:
On the other hand, if you can tell the exact character in the story, that should fit into the first text frame, you could change the leading of all characters from the beginning of the story up (and including) to this character until the character is the last one in the first text frame. It could be that due to some circumstances this would "never" happen. So you have to implement some controls. Like a minimum or a maximum leading. Or you would decide to change the width and/or the height of the text frame. Whatever fits your needs…
I was going to write a script for a largish book today but I think I'm going to look into the base line method.
I does get a little bit complicated when there are a variety of paragraph styles, like for titles, subtitles, and instructions but I shall give it a go.