//以前的方式是获取系统变量HPSCALE的值,后来发现当图纸切换到布局空间,本值变成1,保存图纸后,重新打开,再次切换到模型空间,天正右下角显示的比例是模型空间的比例,比如11:100,但是本值还是1,并未改变。只有手动切换比例后,本值才改变。
[System.Security.SuppressUnmanagedCodeSecurity] [DllImport("accore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "?acedEvaluateLisp@@YAHPEB_WAEAPEAUresbuf@@@Z")] private extern static int acedEvaluateLisp(string lispLine, out IntPtr result); public static ResultBuffer EvalLisp(this string arg) { acedEvaluateLisp(arg, out IntPtr rb); if (rb != IntPtr.Zero) { try { ResultBuffer rbb = DisposableWrapper.Create(typeof(ResultBuffer), rb, true) as ResultBuffer; return rbb; } catch { return null; } } return null; } public static double GetTchPScale() { try { var res = "(TGETPSCALE)".EvalLisp(); if (res != null) { var typedValues = res.AsArray(); var value = Convert.ToDouble(typedValues[0].Value); return value < 1.0 ? 1 : value; } } catch { return 1.0; } return 1.0; }