How to read current command prompt value

Discussion in 'AutoCAD' started by Uwe W. Radu, Jun 26, 2003.

  1. Uwe W. Radu

    Uwe W. Radu Guest

    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
     
    Uwe W. Radu, Jun 26, 2003
    #1
  2. Uwe W. Radu

    wivory Guest

    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
     
    wivory, Jun 27, 2003
    #2
  3. Uwe W. Radu

    Uwe W. Radu Guest

    ThisDrawing.SendCommand "copyhist" & vbCr
    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
     
    Uwe W. Radu, Jun 27, 2003
    #3
  4. Uwe W. Radu

    Jürg Menzi Guest

    Uwe

    How about document's Begin-/EndCommand events?

    Cheers
     
    Jürg Menzi, Jun 27, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.