I just posted this macro, which I hope will help:
MACRO: Cascade All Windows for An App V2 [Example]
I just realized that it is also cascading windows like Peter's example, but maybe it will better lend itself to repurposing. It does make use of the current front (active) screen, and the number of windows in the app.
If you have any questions about the macro, please post them in that topic.