Dear Everybody,
I would award the main prize and cigar to Fair59.
Partly for providing what I guess might be the right answer.
Above all for guessing what may or may not be the right intended question.
Dear @mhillis, you might want to hone your question asking skills a bit.
Is this an accurate description of your needs?

Question: Given points p1 and p2, what is the distance between them, measured along the line L?
If that is indeed what you need, you are actually not asking about the distance between the points at all.
These two points, together with the direction w of L, define two planes.
You are asking about the distance between those two planes.
Are you?
If so, Fair's answer is absolutely accurate and can be reformulated as:
Answer:
v = p2 - p1
w = L.direction.normalise
distance_along_w = v.dotProduct( w )
Unfortunately, the Revit geometry API is not full-fledged and therefore lacks a method to return the distance between two planes.
Otherwise, that would probably provide an even more straightforward path.
The suggested one is very direct and efficient, though, and hard to beat in those respects.
I hope this helps and that we collectively succeeded at nailing your intention.
Best regards,
Jeremy