how to position a point on a line?thank you!

I have drawn lines in the scene, now I want to press mouse button down on a line to select the line and then draw a point at the right position on this line. I can do the selection, but how to position the point? first ,I try to get the intersection of the line(though the mouse down position with gluUnProject() at z=0.0 and z=1.0) and the selected line. But it seems that not all lines have intersection, so would you help me please ? Thank you very much!

ok ,now i get it .i just get the two points on esch of the lines which have the nearest distance,then put the average coordinates of the two points as the new point’s coordinate,and the point is on the selected line.thank you ! :slight_smile: