81 lines
3.4 KiB
C#
81 lines
3.4 KiB
C#
|
|
using Bentley.MstnPlatformNET;
|
|||
|
|
|
|||
|
|
namespace Mstn.Toolkit.Helpers
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取到的内部存储的分辨率值除以对应的UnitHelper中的比值,获取到单位下的数值
|
|||
|
|
/// 新建元素时,需要乘以对应的比值,得到内部存储的分辨率值
|
|||
|
|
/// </summary>
|
|||
|
|
/// <remarks>
|
|||
|
|
/// <para><![CDATA[获取的内部存储的分辨率值是10000,如果主单位是米,则除以UorPerMas(主单位比值),获得(10000/UorPerMas)主单位,即(10000/UorPerMas)米]]></para>
|
|||
|
|
/// <para><![CDATA[获取的内部存储的分辨率值是10000,如果子单位是毫米,则除以UorPerSub(子单位比值),获得(10000/UorPerSub)子单位,即(10000/UorPerSub)毫米]]></para>
|
|||
|
|
/// <para><![CDATA[获取的内部存储的分辨率值是10000,则除以UorPerMeter(米的比值),获得(10000/UorPerMeter)米,]]></para>
|
|||
|
|
/// </remarks>
|
|||
|
|
public static class UnitHelper
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 分辨率单位与主单位的比值,最常用的值
|
|||
|
|
/// </summary>
|
|||
|
|
public static double UorPerMas { get; } = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 分辨率单位与子单位的值
|
|||
|
|
/// </summary>
|
|||
|
|
public static double UorPerSub { get; } = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerSub;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 分辨率单位与米的比值,不随主、子单位设置而改变
|
|||
|
|
/// </summary>
|
|||
|
|
public static double UorMeter { get; } = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMeter;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 转为分辨率单位
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static double ToInternal(this double value)
|
|||
|
|
{
|
|||
|
|
return value * UorPerMas;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 内部分辨率转为主单位值
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static double ToMasterUnit(this double value)
|
|||
|
|
{
|
|||
|
|
return value / UorPerMas;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 内部分辨率转为子单位值
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static double ToSubUnit(this double value)
|
|||
|
|
{
|
|||
|
|
return value / UorPerSub;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 内部分辨率转为米
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="value"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static double ToMeter(this double value)
|
|||
|
|
{
|
|||
|
|
return value / UorMeter;
|
|||
|
|
}
|
|||
|
|
//public static void CreateByKeyin(string unparsed)//Case:CreateByKeyin
|
|||
|
|
//{
|
|||
|
|
// Session.Instance.Keyin("PLACE SPHERE ICON;" +
|
|||
|
|
// "Point absolute 4.656,-0.087,0.000;" +
|
|||
|
|
// "Point absolute 5.523,0.864,0.341"
|
|||
|
|
// ); //模拟输入Key-in
|
|||
|
|
// Session.Instance.Keyin("PLACE SLAB ICON");
|
|||
|
|
// Session.Instance.Keyin("Point absolute 5.351,2.928,0.000");
|
|||
|
|
// Session.Instance.Keyin("Point absolute 6.778,2.818,-0.936");
|
|||
|
|
// Session.Instance.Keyin("Point absolute 6.205,4.712,1.093");
|
|||
|
|
// Session.Instance.Keyin("Point absolute 0.895,9.718,-7.598");
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|