I'm trying to write a simple script to prompt for two points and draw the line between them. It works completely fine, until the part "promptForPoint(promptMsgEnd)" where if the users cancels during the command (hits ESC) the entire program crashes with a fatal exception. Is my approach to transient graphics reasonably correct? How do I properly handle the user cancelling?
IntegerCollection ints = new IntegerCollection(new int[] { });
TransientManager ctm = TransientManager.CurrentTransientManager;
Line l = new Line(startPoint, new Point3d(startPoint.X + 0.00000001, startPoint.Y, startPoint.Z));
ctm.AddTransient(l, TransientDrawingMode.DirectShortTerm, 128, ints);
//handle event - pointer movement
PointMonitorEventHandler handler =
delegate (object sender, PointMonitorEventArgs e)
{
l.EndPoint = e.Context.RawPoint;
ctm.UpdateTransient(l, ints);
};
//add handler for visual
_editor.PointMonitor += handler;
//prompt for point
ppr = promptForPoint(promptMsgEnd);
//remove handler and erase
_editor.PointMonitor -= handler;
ctm.EraseTransient(l, ints);