I noticed this issue on the following sequence:
1) Use "S" option to align leaders by "Y" direction.
2) Leader Flips to opposite side (shouldn't do this)
3) Grip stretch the leader to the correct side.
4) Start UL again and select "S" option to align leader segments again.
5) After selecting leader to align, I get an "Automation Error: Invalid Input", and the leader is missing its dogleg.
4) if I use "Undo" - it goes back to the point before I did the grip stretch. (If think you need to close the Undo mark in your error traping routine)
my command Line:
Command: UL
Pick starting point of leader [Select leader to change or align to]: s
Select leader that is to be aligned [Multiple/alignX/** alignY **/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:
** STRETCH **
Specify stretch point or [Base point/Copy/Undo/eXit]
Command: *Cancel*
Command: UL
Pick starting point of leader [Select leader to change or align to]: s
Select leader that is to be aligned [Multiple/** alignX **/alignY/** alignangLe **/Note/Typ/Poc(d)/Arrowheads/Exit]:
** Error: Automation Error. Invalid input **
I see three problems here:
1) On the 1st align - It should not flip the leader to the opposite side.
2) the "Automation Error" and resulting leader missing the dogleg.
3) "Undo" should only undo the last attempt at aligning, and not be altering my prior manual Grip Stretch.
Otherwise - So far your program is very nice. I like the automatic alignment feature
EDIT - NOTE: I did not see this problem when using "X" Alignment. However, the Undo still kills my previous Grip Edit. You need to look at where you undo marks are getting set and closed.
EDIT2 - Looking at your code now, I see you have not put in any Undo marks. You could solve that by putting a (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object))) at the beginning of your "c:Uleader" routine, and (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object))) at the end of the routine AND in your Error function.