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()));//根据你设置的类型进行转换
         }
  • 相关阅读:
    小白的Python之路_day1
    Vue---tab切换时不刷新
    Vue---第十五章使用VScode编写第一个脚本
    Vue---第十四章visual studio code使用
    Vue---第十三章基础运算和v-model
    Vue---第十二章批量下载模块
    vue---第十一章全局依赖环境区分
    Vue---第十章全局变量
    Vue---第九章NPM
    hadoop-Rpc使用实例
  • 原文地址:https://www.cnblogs.com/belx/p/9256239.html
Copyright © 2011-2022 走看看