santerdam
You didn't mention what you want to do with the calculated lenght.
Did you have a look at flex rails in your library ? AR can fit this track between two (close) endpoints, with smooth continuation on curves. AR also gives you the lenght of the flex part.
Additional advantage of flex is that you don't need to make a selection of parts in a library.
Sander