Hi Tony (or anybody else that knows),
I have been using the commandline class for some time and it has proved very useful thanks, but I am having trouble getting it to work for a poyline. I have read all of the information I can find but still struggling.
From a click event on a modeless form I want the user to be able to draw a polyline, then on completion process code in the form. I have tried commandline.command("_pline") from the event in the form, called a CommandMethod that calls commandline.command("_pline") both with and without CommandFlags.Session but it doesn't pause for input and continues to the following code.
Is this possible and if so, how should I do it?
You can't use the CommandLine's Command() method directly from an event handler on a modeless UI, as that's the same as using it from a CommandMethod method that has CommandFlags.Session flag applied to it. It's not allowed.
To use that method from a modeless UI event handler, you can define a command method (without the CommandFlags.Session flag), and in that command method you can use Command() and do whatever else you need to do after the command scripting is complete. You can use the Document's SendStringToExecute() method to invoke your custom CommandMethod from the modeless UI event handler.
To pause until a command finishes, you must use a loop and call Command( "\\" ) in the loop. Exit the loop when the CMDACTIVE system variable changes to 0. The CommandLine's Command() method is functionally equivalent to LISP's (command) function, so the approach is just what one does in LISP to pause until a command is complete.
Many thanks for that but I think my main issue will be that all of the code is in the form and I need to run subsequent code in the form after the polyline has been drawn. Once the SendStringToExecute is issued I believe the subsequent code in the form will run asynchronously. Waht if the form is modal?
I've answered that part - it behaves the same if the form is modal; so, does that mean that all subsequent code MUST be in the CommandMetod? If that is the case I have a lot of rewriting to do :-(
The CommandMethod can call a method of the form after the polyine is drawn, but the command method must have a reference to the form to do that, which can be solved using a singleton pattern that provides a static property on the form class that returns the form instance..