Re: Nested commands, command during point input
OK, I moved it back. Please be specific in what you want and how the command should work. One of the first things you do in programming is come up with a flow chart or at least a word version of one. For example,
- start the command
- prompt for options, default to point input.
- If input equals option A, then do X
- prompt for second point
- add line to database
It wouldn't be efficient to allow just any kind of input. It should be limited to what is appropriate.
Re: Nested commands, command during point input
Fair enough . . .
I would like to issue the "Line" command. Then when AutoCAD awaits a point input I would like the user to be able to type "Hello". Then I would like a message box (or something similar) to pop up and say "Hello World" back. To extend the functionality a little more if I typed "Circle" instead of "Hello" I would like AutoCAD to quit the line command and start the "Circle" command without an {esc} key or something similar. To extend the functionality even further it would be nice if the "Hello" and "Circle" could be typed any time AutoCAD was awaiting a point input (Line, Circle, Rectangle, Copy, Move, etc.)
To recap:
-Issue "Line" command.
-While AutoCAD awaits point input be able to either provide a point input or type text such as "Hello" or "Circle".
-If the user provides a "point input" have AutoCAD proceed as normal (I.e. ask for second point).
-If the user typed "Hello" or "Circle" instead of providing a point input AutoCAD would message box back with "Hello World" or automatically start a "Circle" command depending on what was entered by user.
Additionally:
The user could enter "Hello" or "Circle" anytime AutoCAD is awaiting a point input. (Event handler?)
Note:
AutoCAD currently does handle certain keyboard inputs while awaiting a point input . . . such as {esc}, {F8}, etc. . .
Re: Nested commands, command during point input
Its possible to watch for commands that are being entered, but not while a command is active. For example, you could watch for the LINE command to execute and then run your own code instead. You would have to redefine each of the commands that you want to accept different input. As you noted, AutoCAD limits input during a prompt for a point and that is as-designed. The intended behavior for 'changing your mind' when a command is active is to simply cancel the command and then do what you want. There are no hooks into a command while it is in-progress. You have to code your own command. Which is easier, replacing numerous commands or hitting the escape key? I understand your desire. I've written commands that only save a keystroke or two, but your broader request of allowing multiple options for multiple commands doesn't make sense...if it were possible.
Re: Nested commands, command during point input
1. So lets start down this road . . . how do I "watch for the LINE command and then execute my own code?
2. How do I make my own code accept a either a point or some text?
Re: Nested commands, command during point input
First, I recommend you download the ObjectArx SDK from here. You will need it's dll's. The \docs folder has help files. You will need these, especially arxmgd.chm. Here is a file I translated for Giles that helps you create a VS template for starting an AutoCAD solution. It references the necessary dll's from the ObjectArx dev package.
It isn't really necessary to watch for the LINE command to start. You can just start your own MyLine command. But if you want to, you use the Document.CommandWillStart event.
The way you allow for multiple inputs is to properly set up a prompt using keywords according to AutoCAD's standard prompt system. You would first prompt the user: "Create a line. [optionA optionB]<Select start point>: ".
The first text is an instruction prompt. The text in [] are options and the capital letters indicate the key the user can use to select the option. The text in <> is the default option. A user would pick a point or hit A or B. You set this up using Autodesk.AutoCAD.EditorInput.PromptKeywordOptions. Then you test the return of the prompt. If its optionA, do X. If it's a point, store that and issue the prompt for the end point.
That's all the time I have for now. Gotta get back to work.