Make the lines with closest points

I want to find the closest points between existing points and lines and connect them. If the nearest straight line is very far away from other straight lines, in other words, if there is no line segment on the nearest side, it does not connect the straight line or connect to the the nearest point where is not perpendicular. Can somebody help me?

p.s.
Input : Pt, Crv
Output : results 1 or results 2

ex3.gh (3.7 KB)

Hello
you didn’t internalize your data.
It could be more clear if you include a little drawing of what you want, like that

I’m terribly sorry. I thought I internalized the data. I changed my file. Please check it.