.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Load lisp app from c# code and wait until it finish

3 REPLIES 3
Reply
Message 1 of 4
ashrafa33
251 Views, 3 Replies

Load lisp app from c# code and wait until it finish

i have a lsp app that select lines and get there proerties and save them to file

i want to run this app from c# code

but when i run it from c# code the c# countine working and when it read the txt file it found it empty 

after while the file will have the lines properties from lisp file

3 REPLIES 3
Message 2 of 4

Should others reading your post guess what your code does?

 

Post your code.

 

You have to define a C:XXXX command function in your LISP file that runs the operation, and then call it from the Application.Invoke() method. You also have to call (vl-acad-defun) to register your command function so that it can be called by Invoke().

 

 

Message 3 of 4
ashrafa33
in reply to: ashrafa33

Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
try
{
doc.SendStringToExecute("(load \"test.lsp\") ", true, false, false);
doc.SendStringToExecute("test_to_start" + "\n", true, false, false);
doc.LispEnded += new EventHandler(OnLispEnded);

MessageBox.Show("it continue" );
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show(ex.ToString() );
}

i tried doc.LispEnded += new EventHandler(OnLispEnded);

but i did not help

(setq JS (SSGET (LIST '(0 . "LINE,ARC,POLYLINE"))))

so it give the Message ("it continue" ) before ssget

Message 4 of 4

That code will not work (post code using the insert code button on the toolbar).

 

SendStringToExecute() does not execute the string until after the managed code that calls it returns. You can't wait for it.  You can use Application.Invoke() to call the LISP if you define it as a C:XXXX command function and use (vl-acad-defun) to register it.

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta