//https://blog.csdn.net/qq_21489689/article/details/78973787 [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("accore.dll", EntryPoint = "acedPutSym", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] extern static private int acedPutSym(string args, IntPtr result); /// <summary> /// Set a LISP variable value. /// </summary> /// <param name="name">The variable name.</param> /// <param name="rb">The variable value</param> public static void SetLispSym(string name, ResultBuffer rb) { acedPutSym(name, rb.UnmanagedObject); } [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("accore.dll", EntryPoint = "acedGetSym", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] extern static private int acedGetSym(string args, out IntPtr result); /// <summary> /// Get a LISP variable value. /// </summary> /// <param name="name">The variable name.</param> /// <returns>The variable value or null if failed.</returns> public static ResultBuffer GetLispSym(string name) { IntPtr ip = IntPtr.Zero; int status = acedGetSym(name, out ip); if (status == (int)PromptStatus.OK && ip != IntPtr.Zero) { return ResultBuffer.Create(ip, true); } return null; } //当然,要读取这个变量,首先要设置或者加载这个变量 ResultBuffer rb1114c = GetLispSym("dydj"); float intRetio=1; foreach (TypedValue val in (System.Collections.IEnumerable)rb1114c) { intRetio = (float)Convert.ToDouble((val.Value.ToString()));//根据你设置的类型进行转换 }