This was taken from Tony's example
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
private static extern int acedInvoke(IntPtr args, out IntPtr result);
public ResultBuffer InvokeLisp(ResultBuffer args, ref int stat)
{
IntPtr rb = IntPtr.Zero;
stat = acedInvoke(args.UnmanagedObject, out rb);
if (stat == (int)PromptStatus.OK && rb != IntPtr.Zero)
return (ResultBuffer)DisposableWrapper.Create(typeof(ResultBuffer), rb, true);
return null;
}
private void PrintResbuff(ResultBuffer res)
{
string s = "\n--------------------";
foreach (TypedValue val in res)
{
s += string.Format("\n{0}->{1}", val.TypeCode, val.Value.ToString());
}
s += "\n---------------------";
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(s);
}
Call it like this
var args = new ResultBuffer();
int stat = 0;
args.Add(new TypedValue((int)LispDataType.Text, "Lisp_Function"));
args.Add(new TypedValue((int)LispDataType.ObjectId, myObject.ObjectId)); //// My fake LISP routine needs an ObjectId and A Point3d
args.Add(new TypedValue((int)LispDataType.Point3d, new Point3d(0, 0, 0)));
ResultBuffer res = InvokeLisp(args, ref stat);
if (stat == 5100 && res != null)
PrintResbuff(res);
res.Dispose();