Passing textbox value to lisp function

Passing textbox value to lisp function

bahman.jf.68
Advocate Advocate
471 Views
3 Replies
Message 1 of 4

Passing textbox value to lisp function

bahman.jf.68
Advocate
Advocate

Hi all,

I have designed windows form via C# for a lisp program. I need to pass some text boxes value on windows form to Lisp function then running the function.

Is it possible ? 

0 Likes
472 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant

Hi,

 

You should provide more details. How do call the C# from LISP? If you use C# LispFunction method, this method can simple return a TextBox contents as a ResultBuffer which will be seen as a LISP list on the LISP side.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

bahman.jf.68
Advocate
Advocate

I don't want to call C# from Lisp, 
I designed a form with C# .Net and user runs the form with command then filling the textboxes on the form. After clicking a button, all data (textboxe's values) should pass to a Lisp Function.

Suppose I have a Lisp Function like this : 

(defun drawcircle (dm txt)

(setq pt (getpoint "Pick a point to add cricle")

(command "circle" pt "d" dm)

(command "text" "j" "mc" pt 2 0.0 txt)

)

 

There are two arguments in this function and this values should be run from C# with this values of the form. (The user enter diameter and the text on form)

0 Likes
Message 4 of 4

_gile
Consultant
Consultant

To call a LISP function, you should use Application.Invoke() method. To make the function accessible, you have to use vl-acad-defun on the LISP side: (vl-acad-defun 'drawcircle).

 

var args = new ResultBuffer(
    new TypedValue((int)LispDataType.Text, "drawcircle"), // <- LISP function name
    new TypedValue((int)LispDataType.Double, double.Parse(textBoxDm.Text)), // <- dm argument
    new TypedValue((int)LispDataType.Text, textBoxTxt.Text)); // <- txt argument
Application.Invoke(args);

 

 

IMHO, trying to mix LISP and .NET is most of the time more complex and less robust than converting the LISP part into .NET.

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub