• AutoCAD二次开发(.Net)之获取LSP变量的值


    //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()));//根据你设置的类型进行转换
         }
  • 相关阅读:
    SP338 ROADS
    [Usaco2008 Mar]牛跑步
    [Cerc2005]Knights of the Round Table
    [Poi2005]Piggy Banks小猪存钱罐
    Pku1236 Network of Schools
    PKU2186 Popular Cows 受欢迎的牛
    黑暗城堡
    入门OJ:最短路径树入门
    Sqli-labs
    Sqli-labs
  • 原文地址:https://www.cnblogs.com/belx/p/9256239.html
Copyright © 2020-2023  润新知