ClosestPt will also help here… same idea.
Here’s a quick Python to move the line to the curve to the target tangent in cases where that is possible.
import rhinoscriptsyntax as rs
crvId1 = rs.GetObject("Select the curve to move", 4, preselect=True)
if crvId1 is None: return
crvId2 = rs.GetObject("Select the target object", 4+8+16, preselect=False)
if crvId2 is None: return
Id, p1, p2 = rs.CurveClosestObject(crvId1, crvId2)
Works with surfaces & polysurfaces as the target as well, bonus!
A smarter way would be to check if the closest point on the target curve has a tangent parallel to the moved curve at its end of the closest point line, and not move the curve if the tangents are not parallel. And if it’s a line move the end point not the closest point…etc.