Command Result

Command Result

AK_UPPALA
Contributor Contributor
221 Views
3 Replies
Message 1 of 4

Command Result

AK_UPPALA
Contributor
Contributor

I am executing a lisp command using c#, how can we get result of that command?

Your response is much appreciated.

 

string _cmd = "(" + "command " + "\"" + "SCRIPT" + "\" " + "\"" + _str_scriptpath + "\"" + ")";
SendCommandSynchronously(_Doc_Opnd, _cmd);

 

 

@KeanM 

0 Likes
Accepted solutions (1)
222 Views
3 Replies
Replies (3)
Message 2 of 4

KeanM
Explorer
Explorer

Is there a reason you have tagged me?  I don't have any experience with this.

0 Likes
Message 3 of 4

KeanM
Explorer
Explorer

I have not used LISP scripting in a long time, but I think if you need to return something the easiest way might be to use the AutoLISP file handling functions to write your data to a known file that the C# code can then read the result from.

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor
Accepted solution

You did not show the code in SendCommandSynchrously() method; nor you mentioned the code uses AutoCAD COM API or .NET API.

 

Also, it looks like the LISP command runs a script, which can be macros of multiple commands, or be one or more LISP command in it. So, it is very difficult to say for sure what kind of output/result of the script execution would be.

 

On the other hand, if you want to call a pure LISP function that returns some data (not all LISP functions  are designed to return some data other than nil), you can use .NET API to run the LIST function: 

 

ResultBuffer result = Application.Invoke([Input ResultBuffer]);

 

where the [input ResultBuffer] include the lisp function name, and expected inputs required by the lisp function. Of course, the LISP function should have been pre-loaded.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes