I've been playing with some late binding, Interop and Reflection.
This will work. (You don't need an Interop reference to Autocad since late binding is used:
public static void SetModeMacro(string value)
{
object[] parameters;
object acadapp = null;
object cmd = null;
object dwg = null;
acadapp = (object)Marshal.GetActiveObject("AutoCAD.Application");
dwg = acadapp.GetType().InvokeMember("ActiveDocument",
BindingFlags.GetProperty, null, acadapp, null);
string sTemp = "(Command " + @"""" + "MODEMACRO" + @"""" + " " + @"""" +
value + @"""" + " )" + "\r";
parameters = new object[1];
parameters[0] = sTemp;
cmd = dwg.GetType().InvokeMember("SendCommand",
BindingFlags.InvokeMethod, null, dwg, parameters);
}
I'd be interested in opinions as to which method to use.