zoukankan      html  css  js  c++  java
  • 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()));//根据你设置的类型进行转换
         }
  • 相关阅读:
    文件监控(教学版)
    设备读写 之 直接方式(Direct I/O)
    过滤驱动加密文件(代码)
    Why ASMLIB and why not?
    SQL调优:Clustering Factor影响数据删除速度一例
    监控一个大事务的回滚
    crsctl status resource t init in 11.2.0.2 grid infrastructure
    Script:收集Oracle备份恢复信息
    Only ARCH Bgprocess may create archivelog?
    11g新特性:A useful View V$DIAG_INFO
  • 原文地址:https://www.cnblogs.com/belx/p/9256239.html
Copyright © 2011-2022 走看看