have a look at this code and see if it will work for what you need.
A lispfunction in a loaded dll
namespace Autodesk.AutoCAD.NetInvoke
{
public class MyCommands
{
[LispFunction("MyLispFunction")]
public ResultBuffer MyLispFunction(ResultBuffer args)
{
List<TypedValue> list = new List<TypedValue>(args.AsArray());
list.Reverse();
ResultBuffer rb = new ResultBuffer(list.ToArray());
return rb;
}
}
}
and the caller in another loaded dll
namespace Autodesk.AutoCAD.NetInvoker
{
public class MyCommands
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
extern static int acedInvoke(IntPtr rbIn, out IntPtr rbOut);
public static ResultBuffer Invoke(ResultBuffer rbIn)
{
IntPtr pRb = IntPtr.Zero;
acedInvoke(rbIn.UnmanagedObject, out pRb);
return DisposableWrapper.Create(typeof(ResultBuffer), pRb, true) as ResultBuffer;
}
[CommandMethod("doit")]
public void MyCommand()
{
ResultBuffer rbOut = new ResultBuffer();
rbOut.Add(new TypedValue((int)LispDataType.Text, "MyLispFunction"));
rbOut.Add(new TypedValue((int)LispDataType.Int32, 1));
rbOut.Add(new TypedValue((int)LispDataType.Int32, 2));
rbOut.Add(new TypedValue((int)LispDataType.Int32, 3));
ResultBuffer rbIn = Invoke(rbOut);
List<TypedValue> list = new List<TypedValue>(rbIn.AsArray());
list.ForEach( X =>
ApplicationServices.Application.DocumentManager.
MdiActiveDocument.Editor.WriteMessage(X.Value.ToString()));
}
}
}
edit: added solution