I am not an expert but there are a few things that might help:
1 - Try to avoid LINQ and use revit filters instead (however it is a one time thing in your code and shouldn't really matter.
2 - I would say use foreach to implement the loop and avoid using ElementAt (I think it is not very efficient)
3 - Another thing that I think would improve the efficiency is to do all the analysis in a separate thread than your RevitAPI-calling thread. So your plugin would calculate and analyze oldPoint and tempPoint in one thread and does the transaction and creates lines in the main thread.
4 - I would like to know your findings if you tried any of these or even a different approach.