Application.Invoke returns eInvalidInput

Application.Invoke returns eInvalidInput

Anonymous
Not applicable
1,785 Views
1 Reply
Message 1 of 2

Application.Invoke returns eInvalidInput

Anonymous
Not applicable

Hi,

I have been fighting this one for a while now. I need to be able to read the return value from a lisp function this would return in lisp T or nil

 

 I have somthing like this in c# with Autocad 2013/ARX 2013

 

 

string path = @"C:/script.LSP";
string cmd = string.Format("(load \"{0}\") ", path);
doc.SendStringToExecute(cmd, true, false, true);

 

ResultBuffer pa = new ResultBuffer();
pa.Add(new TypedValue(5005, "c:issignedin"));

 

ResultBuffer rb = new ResultBuffer();

rb = Application.Invoke(pa); //here I get eInvalidInput
ed.WriteMessage(rb.ToString());

 

There is no much info out there and none of it has helped me so far.

Any ideas?

 

Thanks in advance,

0 Likes
Accepted solutions (1)
1,786 Views
1 Reply
Reply (1)
Message 2 of 2

ActivistInvestor
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Hi,

I have been fighting this one for a while now. I need to be able to read the return value from a lisp function this would return in lisp T or nil

 

 I have somthing like this in c# with Autocad 2013/ARX 2013

 

 

@Anonymous path = @"C:/script.LSP";
string cmd = string.Format("(load \"{0}\") ", path);
doc.SendStringToExecute(cmd, true, false, true);

 

ResultBuffer pa = new ResultBuffer();
pa.Add(new TypedValue(5005, "c:issignedin"));

 

ResultBuffer rb = new ResultBuffer();

rb = Application.Invoke(pa); //here I get eInvalidInput
ed.WriteMessage(rb.ToString());

 

There is no much info out there and none of it has helped me so far.

Any ideas?

 

Thanks in advance,


There is plenty of information on this forum that you can search for, explaining why SendStringToExecute() does not behave as you might expect.

 

SendStringToExecute() is not synchronous, meaning that it does not pass the string to the command line until after your method returns and AutoCAD starts polling for input. Because of that, you cannot rely on any side-effects in the code that follows a call to SendStringToExecute().. In your case, the call to Invoke() is most-likely running before SendStringToExecute() passes the string to the command processor, and the LISP file hasn't been loaded yet. The eInvalidInput exception can also occur if you try to call Invoke() from the application context (e.g., CommandFlags.Session).

 

You should probably try loading your LISP file via the startup suite or via a call to (load) in another LISP file that's loaded at startup, because what you're trying to do is somewhat problematic. Is there something about the LISP function you're trying to call that cannot be replicated in managed code?

0 Likes