I bet the Grasshopper component implements Curve.ClosestPoints. See an example file here:
Also, if your geometries are all lines maybe have a read through the entire topic above.
Edit: I see I forgot to upload the file in the linked post, but there’s a screenshot 