unittypeid revitapi
public static class DoubleExtensions
{
/// <summary>
/// Translate double from mm to internal Ft
/// </summary>
/// <param name="value"></param>
/// <returns>New value in Ft</returns>
public static double MmToInternal(this double value)
{
#if RVT2021
return UnitUtils.ConvertToInternalUnits(value, UnitTypeId.Millimeters);
#else
return UnitUtils.ConvertToInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
#endif
}
/// <summary>
/// Translate double from internal Ft to mm
/// </summary>
/// <param name="value"></param>
/// <returns>New value in mm</returns>
public static double InternalToMm(this double value)
{
#if RVT2021
return UnitUtils.ConvertFromInternalUnits(value, UnitTypeId.Millimeters);
#else
return UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
#endif
}
/// <summary>
/// Translate double from degrees to internal radians
/// </summary>
/// <param name="value"></param>
/// <returns>New value in radians</returns>
public static double DegToInternal(this double value)
{
#if RVT2021
return UnitUtils.ConvertToInternalUnits(value, UnitTypeId.Degrees);
#else
return UnitUtils.ConvertToInternalUnits(value, DisplayUnitType.DUT_DECIMAL_DEGREES);
#endif
}
/// <summary>
/// Translate double from internal radians to degrees
/// </summary>
/// <param name="value"></param>
/// <returns>New value in degrees</returns>
public static double InternalToDeg(this double value)
{
#if RVT2021
return UnitUtils.ConvertFromInternalUnits(value, UnitTypeId.Degrees);
#else
return UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_DECIMAL_DEGREES);
#endif
}
}