How to model a sphere between 2 rails?

I am trying to put a sphere so that its size changes according to the offset length for the curve (shown in the image). Is there a way to place the sphere so that it can fit perfectly between the rails?

See the section “train model” on the program

rollercoasterfirstgo (1).gh (38.1 KB)


1- select a point on a rail curve ( PerpFrame or EvaluateCrv)
2- Find Curve Closest point for the other rail.
3- Generate a middle point using Average.
4- Calculate the distance between rail points, and then subtract the 2X the radius of the rail to compensate for rail thickness.

Another method to create using a third point that Identifies the height of the sphere and use the component SphereFit

rollercoasterfirstgo (1).gh (35.9 KB)

Fantastic thank you!