PileCap tags by direction on a detail/model Line

Hi All, I am trying to tag my pile caps in a certain way definy by Detail/Model line like Ideate/Diroots do in their add-ins. But I am not geeting any ideas how i can use these lines (start& end point or Vector direction) to tag by pile caps in a sequence i wanr. I am attaching a snip What i am trying to achhieve.

earlier i thought to use “Surface.ProjectOnTo” node to use these line curves on my pilecps and sort them out.

2nd Method is Dynamo always follow Creation time to sort elements when we assign any values when we use node “Element.SetParameterByName” and try it to tag it will alway sort elments randomly as per there are created in project.

so i thought i can use this trick as i can create lines one by one in the way how i want to tag my pile caps.