How to load a .lsp file using C#?

How to load a .lsp file using C#?

Anonymous
Not applicable
2,865 Views
3 Replies
Message 1 of 4

How to load a .lsp file using C#?

Anonymous
Not applicable

Hello guys,

I want to load a lisp file using C#. here is my code:

Editor ed;
Document doc;
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
string myStr = @"(LOAD ""c:/rigging/Chok.lsp"")";
ed.Command(myStr);

I would appreciate it if you let me know what is wrong with this code?

When I copy and past my string which is (LOAD "c:/rigging/Chok.lsp") in command line it works!

 

Thanks,

0 Likes
Accepted solutions (2)
2,866 Views
3 Replies
Replies (3)
Message 2 of 4

doaiena
Collaborator
Collaborator
Accepted solution

doc.SendStringToExecute ?

Message 3 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

Unlike Document.SendStringToExecute() (or AcadDocument.SendCommand()) which send the string passed as argument to the command line for being executed, the Editor.Command() method requires typed arguments (as the command LISP function).

So, to load a LISP file from .NET, you should use Document.SendStringToExecute() despite the fact it runs asynchronously.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 4

Anonymous
Not applicable

Thanks so much for your response.

0 Likes