.NET

Reply
Contributor
davidcpreston
Posts: 23
Registered: ‎09-14-2006
Message 1 of 5 (153 Views)

Commandline.command with Pline

153 Views, 4 Replies
10-31-2012 08:11 AM

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?

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 5 (145 Views)

Re: Commandline.command with Pline

10-31-2012 08:40 AM in reply to: davidcpreston

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.

Contributor
davidcpreston
Posts: 23
Registered: ‎09-14-2006
Message 3 of 5 (137 Views)

Re: Commandline.command with Pline

10-31-2012 08:48 AM in reply to: DiningPhilosopher

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?

Contributor
davidcpreston
Posts: 23
Registered: ‎09-14-2006
Message 4 of 5 (129 Views)

Re: Commandline.command with Pline

10-31-2012 09:34 AM in reply to: davidcpreston

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 :-(

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 5 of 5 (118 Views)

Re: Commandline.command with Pline

10-31-2012 01:36 PM in reply to: davidcpreston

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..

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community