It would be relatively easy to use find/change to identify the last paragraph in a story, but I can't think of an automatic way to determine if a paragraph is the last, and once you change the style (and I think that, too, is a given) there is no automatic way to "unchange" if if more text is added a the end.
It would be really easy using a GREP style, but for reasons unknown, it only allows you to set a Character Style and not another Paragraph Style...
Not reasons unknown. GREP styles are designed to apply character styles to selected text within a paragraph, not to alter an entire paragraph.
What I mean is, the mechanic is there, but they have chosen to only allow character styles which is unnecessarily limiting.
What do you mean "the last paragraph in the section"? What, in your
case, is a "section"?
Just wherever I have applied that paragraph style.
So for example, I might have a textbox with three paragraphs in which case I'd want 2 paragraph rules in total (ie none at the beginning or end).
That is unless there is an entirely different way to achieve this effect?
It could be scripted. What OS are you using?
Which is still not an automated solution. You would need to have the script check to be sure a paragraph that the rule is removed from is still the last paragraph in the frame and restore it if it is not, as well as remove the rule from any new "last" paragraphs, and it would need to be run after every edit.
I'm curious, too, now that this seems to be a frame-based rather than story-based request, how one deals with a paragraph split between frames?
Which is still not an automated solution...it would need to be run after every edit.
Right it wouldn't be completely automatic, but you wouldn't have to run it after every edit—just after the final edit.
It isn't clear if the text is flowing between frames, the OP's #6 makes it sound like it's 1 frame. If it is flowing you can check if a paragraph's last line is the last line of a frame, so it still could be done with flowing text.
So this AppleScript gets every story in the document and checks the story's paragraphs. If the paragraph has a style sheet applied with rule below on and it's the last paragraph, the rule below gets turned off, otherwise the rule gets turned on.
tell application "Adobe InDesign CC 2014"
tell active document
--get the document stories
set s to every story
repeat with x in s
--check each paragraph
set ps to object reference of every paragraph of x
repeat with i from 1 to count of ps
set p to item i of ps
--if it's the last paragraph and the p style has a rule below set it to off, else make sure it is on
if i is equal to (count of ps) then
if rule below of applied paragraph style of p then set rule below of p to false
if rule below of applied paragraph style of p then set rule below of p to true
In response to the split paragraph question, none of it will be flowing so that won't happen in this case.