Any idea on a recursive setout script?


I am preparing a setout script that creates rational panel setouts based on a list of points.
Each module size is 800mm.

The workflow that I have tried is:
An input list of points is arranged along a curve.
Between each point is x distance. This distance needs to be divisible by 800.
If not, the point is moved to the closest integer (in any direction) that is divisable by 800.
The script then takes this new point and calculates the same algorithm with the following point and so on, until it reaches the last point.

At the end, we will arrive with a list of points on the curve that have “jumped” a minimal distance from their respective starting points so that the curve contains divisions that can be divisble by 800.

Attached is a screenshot for reference.

Any help is greatly appreciated!

If case points are always colinear… (11.6 KB)