Hi,
Please see the attached file for a possible solution. Thankfully because at least one end was flat (the top in this case) it can be done using the following expression wire the X Size input of the segment.
return abs(XSplineCoords.z);
XSplineCoords.z return the distance between the segment's current position on the spline to the RailClone Object's pivot. Because in this case the flat part is on top, you'd need to move the RailClone object on the Z Axis so that it's at the same level as the top of the glazing. Because the RailClone object is then above the spline, the distance would be negative. Adding abs() fixes that, making a negative value a positive.
I hope that helps,
Paul