What am I doing wrong here? the objectARX docs say that acedGetVar returns a resultbuffer.
Anyway here is my code, Thanks a ton
edit This is for AutoCAD 2005 & VS2005 /edit
Dan
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
//
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
namespace Dans.Utilities
{
public class Utilities
{
const short RTNORM = 5100;
[CommandMethod("test")]
public void tmp()
{
acedAlert(GetVar("OFFSETDIST").ToString());
}
//
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
internal static extern int acedAlert(string prompt);
//-===-==-==-==-=-=-==-=-==-=-==-=-=-==-=-=-=-=-==-=-=-=-=-==-=-==-
//VVVV This Does not work VVVV
//-===-==-==-==-=-=-==-=-==-=-==-=-=-==-=-=-=-=-==-=-=-=-=-==-=-==-
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
static internal extern int acedGetVar(string prompt, out IntPtr ptr);
//
public static int GetVar(string title)
{
IntPtr ptr = IntPtr.Zero;
ResultBuffer rb = new ResultBuffer();
if (acedGetVar(title, out ptr) == RTNORM)
{
try
{
rb = (ResultBuffer)DisposableWrapper.Create(typeof(ResultBuffer), ptr, true);
ArrayList arl = new ArrayList();
foreach (TypedValue val in (IEnumerable)rb)
{
arl.Add((object)val.Value);
}
return arl.Count;
}
catch
{
// put an exception here
}
finally
{
rb.Dispose();
}
}
return (int)0;
}
}
}