How to read current command prompt value

How to read current command prompt value

Anonymous
Not applicable
758 Views
4 Replies
Message 1 of 5

How to read current command prompt value

Anonymous
Not applicable
I know this is asked once in a while, but it never seems to be answered in a
satisfactory way (which, of course, could be an answer all in itself). I
need to obtain the string currently being displayed as the command prompt
when AutoCAD is NOT idle (or "quiescent").

I have a batch plotting process that plots drawings dropped in a watched
directory, and it controls AutoCAD via commands sent with SendCommand(). If
the drawing loads fine and there are no problems, the command sequence works
out fine and everything is peachy. If however anything goes wrong, like a
drawing contains fonts that aren't installed and AutoCAD promts the user for
input, this disrupts the whole process. If any given command doesn't
complete normally, with AutoCAD prompting the user for some input, I want to
log this prompt to an error file, kill the session, and move on to the next
drawing.

I can detect whether AutoCAD is not idle after a command by checking
IsQuiescent, but I can't figure out how to obtain the prompt string being
displayed to the user. When AutoCAD is idle, you can use GetVariable() with
"lastprompt" or "cmdnames", but when it's not idle, those won't work. What
other options do I have?

Thanks!

Uwe W. Radu
0 Likes
759 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I'm not sure if this will work in your particular situation, but I have put the following code into my project when I've received an unexpected result from a SendCommand.


DoEvents
ThisDrawing.SendCommand "copyhist" & vbCr

This copies the entire command history to the Windows Clipboard. In my case that's all I have the program do and I open the clipboard manually to examine what happened, but if you wanted to get fancy you could use the Clipboard.GetText method to...



Oh. I was just checking that out and discovered that although the Clipboard object is available in VB6, for some reason it's not available in my AutoCAD 2002's VBA6! Well, perhaps you could still make some use of this by using the Shell function to run something external and using the SendKeys statement to make it paste the text. It would make it harder to just get the last line (containing the error message) though.



Regards



Wayne Ivory

IT Analayst Programmer

Wespine Industries Pty Ltd
0 Likes
Message 3 of 5

Anonymous
Not applicable
> ThisDrawing.SendCommand "copyhist" & vbCr
> [...] Well, perhaps you could still make some use of this

Thanks for the suggestion, this is an extra command that I now know.
Accessing the clipboard isn't a problem, since this is a stand-alone VB app
that controls AutoCAD externally via automation. The problem is that by the
time I know that a command hasn't returned (and most likely led to some sort
of prompt), it is too late to send the "copyhist" command to AutoCAD, since
it doesn't accept commands when not quiescent. The logic goes like this:

SendCommand()
' since most commands execute synchronously, AutoCAD should be
' idle again when returning from the call
if not Quiescent then
' something went wrong--obtain command prompt to see what
' AutoCAD wants and to log it to error file
' --at this point you can't execute any SendCommand statements
' because AutoCAD isn't idle
end if

Anyway, "copyhist" might still come in handy at some point. Thanks!

Uwe W. Radu
0 Likes
Message 4 of 5

Anonymous
Not applicable
Uwe

How about document's Begin-/EndCommand events?

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch
0 Likes
Message 5 of 5

Anonymous
Not applicable
> How about document's Begin-/EndCommand events?

Well, I tried that, too. The thing is, the EndCommand doesn't get raised
until AutoCAD is idle again after a command. Here is a sample sequence:

SendCommand("-plot")
' 1. BeginCommand event is raised with "-PLOT" as command
' 2. AutoCAD displays "Detailed plot configuration? [Yes/No] :"
' 3. SendCommand() returns and the following line is executed
if not Acad.GetAcadState.IsQuiescent then
' Since AutoCAD is still expecting input, IsQuiescent is FALSE, and
' no other commands can be issued at this time.
' I would REALLY like to be able to obtain the
' "Detailed plot configuration..." prompt at this point, so I can log it
' to the error file.
end if

Of course, this is a contrived case, since the "Detailed plot" prompt is
always the first thing displayed when issuing "-plot". But take a case like
a drawing using fonts that are not installed, and AutoCAD prompting for font
mapping info. I would like to kick out a drawing like that with an error,
the error being the prompt that AutoCAD displays. The user can then look at
the error file and realize that some new fonts must be configured on this
machine. After that the user can run the drawing again, hopefully succeeding
this time.
0 Likes