This small script below returns the index number of a starting paragraph and the ending paragraph selected within the active Story. How do we not count paragraphs with no printable characters?
Ultimately we are trying to incorporate into a spacing script, were the user can select paragraphs in one story to adjust leading, and then the script will calculate the matching paragraph in the other story, adjusting it as well. We are using insertionPoints and paragraphs as reference points.
myTF = app.selection[0].parentTextFrames[0];
myText = app.selection[0];
startParaIndex = myText.parentStory.insertionPoints.itemByRange (myTF.insertionPoints[0].index, myText.index).paragraphs.length;
endParaIndex = myText.parentStiry.insertionPoints.itemByRange (myTF.insertionPoints[-1].index, myText.index).paragraphs.length;
alert("Start : " + startParaIndex + "\n End : " + endParaIndex);