Define the LISP:Code - C#: [Select]
{ code }
Call the LISP:Code - C#: [Select]
{ code }
But, IMO, you should avoid to mix LISP from .NET this way. Most of the this brings more problems than solutions.
[LispFunction("lisp01")]
// Note: you can return types bool, int, double, Point2d, Point3d, ObjectID, TypedValue,
// ResultBuffer or null to lisp
static public ResultBuffer lisp01(ResultBuffer pArgs)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
try
{
if (pArgs != null)
{
List<TypedValue> inArray = new List<TypedValue>(pArgs.AsArray());
return new ResultBuffer(inArray.ToArray());
}
}
catch (System.Exception ex)
{
_AcAp.Application.ShowAlertDialog(
string.Format("\nError: {0}\nStackTrace: {1}", ex.Message, ex.StackTrace));
}
return null;
}
LispFunction attribute might be of some interest, allows for sending / returning lists and other goodiesCode: [Select][LispFunction("lisp01")]
...
If the issue is about dialog boxes, you can build the dialog box with .NET and expose it to LISP via a LispFunction (i.e. a method which is decored with the LispFunction attribute). If I had to mix .NET and LISP I'd rather do it this way
Here's a trivial example with a simple dialog box containing a TextBox and a NumericUpDown:
Error 9 'LispDialogSample_Gile.Dialog.numericUpDown1' is a 'field' but is used like a 'type'
As you probably guessed I'm a lisp guy, that used DCL to collect user inputs.
Although I got some errors on declaring the public variables from the dialog class -Code - C#: [Select]
public string TextValue => textBox1.Text; public int NumericValue => (int)numericUpDown1.Value;
So my question is how would you pass a string[,] array to the ResultBuffer(); to the LispDataType enum? (say if I initially constructed the string[,] from the DGV's cell values)
Hey .NET developers,
I wanted to ask you if its possible to define a LISP function via C#/.NET , by providing the actual LISP code ?
I mean having the LISP code inside of the .NET code and writing it+defining it on-the-fly.
So basically like passing this into VLIDE's console and defining it:Code - Auto/Visual Lisp: [Select]
Second question: how can you call the LISP function itself, again via .NET ?
As you probably guessed I'm a lisp guy, that used DCL to collect user inputs.
also, don't forget about Open DCL, I think it has a nice grid control.
Although I got some errors on declaring the public variables from the dialog class -Code - C#: [Select]
public string TextValue => textBox1.Text; public int NumericValue => (int)numericUpDown1.Value;
This is C#6 (or later) syntax for property get statement.
As AutoLISP only knows (linked) lists as data structure, you have to convert a 2 dimension array into a list, typically a list of sublists where each sublist represent a row.Code - C#: [Select]
{ code }
Tried that as well when I started. Dive in friend, C#.net is easier than lisp (to me) once the curve is over :)
Typically you do not handle the Click event for the OK and Cancel buttons, you only set their DialogResult property.
As the calling LispFunction creates an instance of the dialog, it can access to all its public instance members (properties and methods) and it's a better practice to expose the data this way.
although I don't understand why I got "Object reference not set to an instance of an object." exception (in the previous code, before your reply).
Because the public property 'Dialog.arrayDGV' is never instantiated.
Ah now I see, Can you specify
was it because I messed-up the case: ArrayDGV with arrayDGV
or it didn't instantiated, because I used it as instance within that same class (... = new ...) -
you never initialize it, you only declare and initialize a local variable with the same name within the btnOk_Click() method, this variable is unknown outside the method
Without reading thread (only reading last post).
That would be a STRUCT.Code - C#: [Select]
public struct Cow { public decimal weight; public string color; public string sex; }
Public/Private ...welcome to the C based languages.
Without reading thread (only reading last post).
That would be a STRUCT.Code - C#: [Select]
public struct Cow { public decimal weight; public string color; public string sex; }
Public/Private ...welcome to the C based languages.
The main difference between LISP and C# is about dynamic vs static typing.
This also one of the main issue when mixing both laguages (with the execution context).
The ResultBuffer (or the TypedValue array) provides a way to communicate between LISP and .NET when collections of different types instance are necessary. Each TypedValue (http://help.autodesk.com/view/OARX/2018/ENU/?guid=OREFNET-Autodesk_AutoCAD_DatabaseServices_TypedValue) embed a Value property (of type Object) and a TypeCode property (of type short) which allows to easily cast the object to its type.
I haven't read the whole thread either but the crux of Lisp<->.net/C/C++ interop is just marshalling data using resbuf's (ResultBuffer in C#) as one parameter rather than many parameters, the rest is just a function call passing the data to the called function at either end. This called function can use this data and if required it then needs to build the result buffer with the results to return the values.
COM is similar but much more involved just to save building resbuf types of structures to marshall data back and forth but that's what's going on under the hood.
If you think of it like that it's easy :)
I thought he was asking a different question at the end about lists in Lisp vs C# -ie. how you can "mix data types" in lisp but not C#. I apologize for my drive-by answer (next time it will be to issue a cat call).
Speaking in C language terms; you don't have to mapcar over a list like you do in Lisp. You can access objects (like the struct example) directly. [Cow.weight] However, you can create a list of Cows and use a foreach to iterate each cow object and pull the weight from each cow.
...
As someone that is not familiar with AutoLisp, I am inferring AutoLisp doesn't have many other data structures besides lists?
I thought I read earlier in the thread that a point was (xx yy zz), how would a BlockTableRecord be represented in AutoLisp?
Is it a list of its properties & methods?
As someone that is not familiar with AutoLisp, I am inferring AutoLisp doesn't have many other data structures besides lists?
I thought I read earlier in the thread that a point was (xx yy zz), how would a BlockTableRecord be represented in AutoLisp?
Is it a list of its properties & methods?
As someone that is not familiar with AutoLisp, I am inferring AutoLisp doesn't have many other data structures besides lists?
I thought I read earlier in the thread that a point was (xx yy zz), how would a BlockTableRecord be represented in AutoLisp?
Is it a list of its properties & methods?