I don't get the first part of your process. Why not just draw a Line from the ENDpoint of the lower line PERpendicular to the upper one? What is the purpose of Offsetting the lower one, and drawing the short line between those ends, that gets Extended to the upper one? Am I missing something?
By the way, never use Object Snap with all Osnap modes turned on. That can cause problems, and there have been multiple topics here caused by it. In particular, don't include NEArest, which will almost always "win" over other modes, and can lead to unexpected results.
lower line PERpendicular to the upper. I missed this feature of Autocad lol. My mistake.
By the way, never use Object Snap While using a few lisp cmds, I m losing my snap settings, and I am fed up with resetting it.
Your CE command in CAPEND.lsp. is a total solution for this task. thank you so much!