Reneczech
well, I had a lot of fun playing with that, and have a good start... I borrowed ideas from a bunch of places - a line following example ROJOhound made a couple years ago, smooth curves for trucks, a wiggly worm demo, etc.
I made two track segments (straight, and a 90 degree curve) that can snap together to make the layout you wanted. It would be easy to make other types of track segments - just have the end line up, and create image points.
if you turn on snap to grid with a grid size of 44x44 pixels it is real easy to place the tracks. You have to make sure to get the arrows on the segments all pointing the same direction - otherwise the waypoints wont get created in the proper order at runtime... the waypoints are created based on image points on the track segments. You also have to assign a sequence number to each section of track so the program knows what order to process them in, when the waypoints are created. (There is a family instance number called SegmentNumber for this).
I changed the layout a little to make a loop so the trains can keep going around and around. Then I thought it should be possible to have multiple tracks... it uses the track name to know which track a waypoint belongs to.
I also made it so that trains can accelerate and slow down and stop - but there are still problems with spacing the wagons. I used a method I helped someone else with (who was making a worm), it keeps a history of where the head has been to position the parts behind it. this works well for keeping the wagons on the tracks around corners. But, I am not sure it is the best way to do this... I might try some other options later this week.
going around curves is not as smooth as I would like either... adding more image points to the tracks might help, but that might add other problems too.
So, hopefully this will give you something to work with.
https://www.rieperts.com/games/forum/traintracks.capx