A couple of possibilities occur to me.
If the spacing is fixed, you could make the first and second picket one component, then have another component for the single picket you want to copy to fit the stretched length, and copy that the right number of times to fill the remaining length of the fence.
You could make one copy at 4cm, then another piece of code to copy the remaining pickets, again, the right number of times to fit the remaining space.
I’m not very experienced in DCs, so others may have better ideas, and I haven’t time now to try either in detail. Sorry