用法:
txt.Text=UnitConvertC.CovertFromAPI(param.AsDouble());
param.Set(UnitConvertC.CovertToAPI(txt.Text));
Parameter parameter = item.get_Parameter(BuiltInParameter.ROOM_DESIGN_COOLING_LOAD_PARAM);
if (null != parameter)
{
coolingDesign += UnitConvertC.CovertFromAPI(DisplayUnitType.DUT_KILOWATTS, parameter.AsDouble());
}//DUT_KILOWATTS千瓦
start
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
namespace revit_5d6d_com
{
/// <summary>
/// 单位转换类
/// </summary>
public sealed class UnitConvert
{
#region Methods
/// <summary>
/// Convert the value get from RevitAPI to the value indicated by DisplayUnitType
/// </summary>
/// <param name="to">DisplayUnitType indicates unit of target value</param>
/// <param name="value">value get from RevitAPI</param>
/// <returns>Target value</returns>
public static double CovertFromAPI(DisplayUnitType to, double value)
{
switch (to)
{
case DisplayUnitType.DUT_FAHRENHEIT://华氏
return value * ImperialDutRatio(to) - 459.67;
case DisplayUnitType.DUT_CELSIUS://摄氏
return value - 273.15;
default:
return value *= ImperialDutRatio(to);
}
}
/// <summary>
/// Convert a value indicated by DisplayUnitType to the value used by RevitAPI
/// </summary>
/// <param name="value">Value to be converted</param>
/// <param name="from">DisplayUnitType indicates the unit of the value to be converted</param>
/// <returns>Target value</returns>
public static double CovertToAPI(double value, DisplayUnitType from)
{
switch (from)
{
case DisplayUnitType.DUT_FAHRENHEIT:
return (value + 459.67) / ImperialDutRatio(from);
case DisplayUnitType.DUT_CELSIUS:
return value + 273.15;
default:
return value /= ImperialDutRatio(from);
}
}
public static double LengthConverFromAPI(Document document, double dLength)
{
UnitType unitType = UnitType.UT_Length;
ProjectUnit projectUnit = document.ProjectUnit;//项目单位
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertFromAPI(formatOption.Units, dLength);
}
public static double LengthConverToAPI(Document document, double dLength)
{
UnitType unitType = UnitType.UT_Length;
ProjectUnit projectUnit = document.ProjectUnit;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertToAPI(dLength, formatOption.Units);
}
public static double AreaConverFromAPI(Document document, double dArea)
{
UnitType unitType = UnitType.UT_Area;
ProjectUnit projectUnit = document.ProjectUnit;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertFromAPI(formatOption.Units, dArea);
}
public static double AreaConverToAPI(Document document, double dArea)
{
UnitType unitType = UnitType.UT_Area;
ProjectUnit projectUnit = document.ProjectUnit;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertToAPI(dArea, formatOption.Units);
}
public static double VolumeConverFromAPI(Document document, double dVolume)
{
UnitType unitType = UnitType.UT_Volume;
ProjectUnit projectUnit = document.ProjectUnit;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertFromAPI(formatOption.Units, dVolume);
}
public static double AngleConverFromAPI(Document document, double dAngle)
{
UnitType unitType = UnitType.UT_Angle;
ProjectUnit projectUnit = document.ProjectUnit;
Autodesk.Revit.DB.FormatOptions formatOption = projectUnit.get_FormatOptions(unitType);
return CovertFromAPI(formatOption.Units, dAngle);
}
/// <summary>
/// 保留两位小数
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
public static string GetString(string offset)
{
decimal val = decimal.Parse(offset);
return val.ToString("0.00");
}
/// <summary>
/// Unit Show String
/// </summary>
/// <param name="dut"></param>
/// <returns></returns>
public static string GetUnitString(DisplayUnitType dut)
{
string s = dut.ToString();
switch (dut)
{
case DisplayUnitType.DUT_CELSIUS: return "C";
case DisplayUnitType.DUT_METERS: return "Meters";
case DisplayUnitType.DUT_ACRES: return "Acres";
case DisplayUnitType.DUT_AMPERES: return "Amperes";
case DisplayUnitType.DUT_ATMOSPHERES: return "atmospheres";
case DisplayUnitType.DUT_BARS: return "Bars";
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS: return "BritishThermalUnits";
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS_PER_HOUR: return "BritishThermalUnitsPerHour";
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS_PER_SECOND: return "BritishThermalUnitsPerSecond";
case DisplayUnitType.DUT_CALORIES: return "Calories";
case DisplayUnitType.DUT_CALORIES_PER_SECOND: return "CaloriesPerSecond";
case DisplayUnitType.DUT_CANDELAS: return "Candelas";
case DisplayUnitType.DUT_CANDELAS_PER_SQUARE_METER: return "CandelasPerSquareMeter";
case DisplayUnitType.DUT_CANDLEPOWER: return "Candlepower";
case DisplayUnitType.DUT_CENTIMETERS: return "Centimeter";
case DisplayUnitType.DUT_CENTIMETERS_PER_MINUTE: return "CentimetersPerMinute";
case DisplayUnitType.DUT_CENTIPOISES: return "Centipoises";
case DisplayUnitType.DUT_CUBIC_CENTIMETERS: return "CubicCentimeters";
case DisplayUnitType.DUT_CUBIC_FEET: return "CubicFeet";
case DisplayUnitType.DUT_CUBIC_FEET_PER_KIP: return "CubicFeetPerKip";
case DisplayUnitType.DUT_CUBIC_FEET_PER_MINUTE: return "CubicFeetPerMinute";
case DisplayUnitType.DUT_CUBIC_INCHES: return "CubicInches";
case DisplayUnitType.DUT_CUBIC_METERS: return "CubicMeters";
case DisplayUnitType.DUT_CUBIC_METERS_PER_HOUR: return "CubicMetersPerHour";
case DisplayUnitType.DUT_CUBIC_METERS_PER_KILONEWTON: return "CubicMetersPerKilonewton";
case DisplayUnitType.DUT_CUBIC_METERS_PER_SECOND: return "CubicMetersPerSecond";
case DisplayUnitType.DUT_CUBIC_MILLIMETERS: return "CubicMillimeters";
case DisplayUnitType.DUT_CUBIC_YARDS: return "CubicYards";
case DisplayUnitType.DUT_CYCLES_PER_SECOND: return "CyclesPerSecond";
case DisplayUnitType.DUT_DECANEWTONS: return "Decanewtons";
case DisplayUnitType.DUT_DECANEWTONS_PER_METER: return "DecaNewtonsPerMeter";
case DisplayUnitType.DUT_DECANEWTONS_PER_SQUARE_METER: return "DecaNewtonsPerSqareMeter";
case DisplayUnitType.DUT_DECANEWTON_METERS: return " DecaNewtonMeters";
case DisplayUnitType.DUT_DECANEWTON_METERS_PER_METER: return " DecaNewtonMetersPerMeter";
case DisplayUnitType.DUT_DECIMAL_DEGREES: return "DecimalDegrees";
case DisplayUnitType.DUT_DECIMAL_FEET: return "DecimalFeet";
case DisplayUnitType.DUT_DECIMAL_INCHES: return "DecimalInches";
case DisplayUnitType.DUT_DEGREES_AND_MINUTES: return "DegreesAndMinutes";
case DisplayUnitType.DUT_FAHRENHEIT: return "Fahrenheit";
case DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES: return "FeetFractionalInches";
case DisplayUnitType.DUT_FEET_OF_WATER: return "FeetOfWater";
case DisplayUnitType.DUT_FEET_OF_WATER_PER_100FT: return "FeetOfWaterPer100ft";
case DisplayUnitType.DUT_FEET_PER_KIP: return "FeetPerKip";
case DisplayUnitType.DUT_FEET_PER_MINUTE: return "FeetPerMinute";
case DisplayUnitType.DUT_FEET_PER_SECOND: return "FeetPerSecond";
case DisplayUnitType.DUT_FIXED: return "Fixed";
case DisplayUnitType.DUT_FOOTCANDLES: return "Footcandles";
case DisplayUnitType.DUT_FOOTLAMBERTS: return "Footlamberts";
case DisplayUnitType.DUT_FRACTIONAL_INCHES: return "FractionalInches";
case DisplayUnitType.DUT_GALLONS_US: return "GallonsUs";
case DisplayUnitType.DUT_GALLONS_US_PER_HOUR: return "GallonsUsPerHour";
case DisplayUnitType.DUT_GALLONS_US_PER_MINUTE: return "GallonsUsPerMinute";
case DisplayUnitType.DUT_GENERAL: return "General"; ;
case DisplayUnitType.DUT_HECTARES: return "Hectares";
case DisplayUnitType.DUT_HERTZ: return "Hertz";
case DisplayUnitType.DUT_HORSEPOWER: return "Horsepower";
case DisplayUnitType.DUT_INCHES_OF_MERCURY: return "InchesOfMercury";
case DisplayUnitType.DUT_INCHES_OF_WATER: return "InchesOfWater";
case DisplayUnitType.DUT_INCHES_OF_WATER_PER_100FT: return "InchesOfWaterPer100ft";
case DisplayUnitType.DUT_INV_CELSIUS: return "InvCelsius";
case DisplayUnitType.DUT_INV_FAHRENHEIT: return "InvFahrenheit";
case DisplayUnitType.DUT_INV_KILONEWTONS: return "InvKilonewtons";
case DisplayUnitType.DUT_INV_KIPS: return "InvKips";
case DisplayUnitType.DUT_JOULES: return "Joules";
case DisplayUnitType.DUT_KELVIN: return "Kelvin";
case DisplayUnitType.DUT_KILOAMPERES: return "Kiloamperes";
case DisplayUnitType.DUT_KILOCALORIES: return "Kilocalories";
case DisplayUnitType.DUT_KILOCALORIES_PER_SECOND: return "KilocaloriesPerSecond";
case DisplayUnitType.DUT_KILOGRAMS_FORCE: return "KilogramsForce";
case DisplayUnitType.DUT_KILOGRAMS_FORCE_PER_METER: return "KilogramsForcePerMeter";
case DisplayUnitType.DUT_KILOGRAMS_FORCE_PER_SQUARE_METER: return "KilogramsForcePerSqareMeter";
case DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER: return "KilogramsPerCubicMeter";
case DisplayUnitType.DUT_KILOGRAM_FORCE_METERS: return "KilogramForceMeters";
case DisplayUnitType.DUT_KILOGRAM_FORCE_METERS_PER_METER: return "KilogramForceMetersPerMeter";
case DisplayUnitType.DUT_KILONEWTONS: return "Kilonewtons";
case DisplayUnitType.DUT_KILONEWTONS_PER_CUBIC_METER: return "KilonewtonsPerCubicMeter";
case DisplayUnitType.DUT_KILONEWTONS_PER_METER: return "KilonewtonsPerMeter";
case DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER: return "KilonewtonsPerSqareMeter";
case DisplayUnitType.DUT_KILONEWTON_METERS: return "KilonewtonMeters";
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE: return "KilonewtonMetersPerDegree";
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE_PER_METER: return "KilonewtonMetersPerDegreepermeter";
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_METER: return "KilonewtonMetersPerMeter";
case DisplayUnitType.DUT_KILOPASCALS: return "Kilopascals";
case DisplayUnitType.DUT_KILOVOLTS: return "Kilovolts";
case DisplayUnitType.DUT_KILOVOLT_AMPERES: return "KilovoltAmperes";
case DisplayUnitType.DUT_KILOWATTS: return "Kilowatts";
case DisplayUnitType.DUT_KILOWATT_HOURS: return "KilowattHours";
case DisplayUnitType.DUT_KIPS: return "Kips";
case DisplayUnitType.DUT_KIPS_PER_CUBIC_FOOT: return "KipsPerCubicFoot";
case DisplayUnitType.DUT_KIPS_PER_CUBIC_INCH: return "KipsPerCubicInch";
case DisplayUnitType.DUT_KIPS_PER_FOOT: return "KipsPerFoot";
case DisplayUnitType.DUT_KIPS_PER_INCH: return "KipsPerInch";
case DisplayUnitType.DUT_KIPS_PER_SQUARE_FOOT: return "KipsPerSquareFoot";
case DisplayUnitType.DUT_KIPS_PER_SQUARE_INCH: return "KipsPerSquareInch";
case DisplayUnitType.DUT_KIP_FEET: return "KipFeet";
case DisplayUnitType.DUT_KIP_FEET_PER_DEGREE: return "KipFeetPerDegree";
case DisplayUnitType.DUT_KIP_FEET_PER_DEGREE_PER_FOOT: return "KipFeetPerDegreePerFoot";
case DisplayUnitType.DUT_KIP_FEET_PER_FOOT: return "KipFeetPerFoot";
case DisplayUnitType.DUT_LITERS: return "Liters";
case DisplayUnitType.DUT_LITERS_PER_SECOND: return "LitersPerSecond";
case DisplayUnitType.DUT_LUMENS: return "Lumens";
case DisplayUnitType.DUT_LUX: return "Lux";
case DisplayUnitType.DUT_MEGANEWTONS: return "Meganewtons";
case DisplayUnitType.DUT_MEGANEWTONS_PER_METER: return "MeganewtonsPerMeter";
case DisplayUnitType.DUT_MEGANEWTONS_PER_SQUARE_METER: return "MeganewtonsPerSqareMeter";
case DisplayUnitType.DUT_MEGANEWTON_METERS: return "MeganewtonMeters";
case DisplayUnitType.DUT_MEGANEWTON_METERS_PER_METER: return "MeganewtonMetersPerMeter";
case DisplayUnitType.DUT_MEGAPASCALS: return "Megapascals";
case DisplayUnitType.DUT_METERS_CENTIMETERS: return "MetersCentimeters";
case DisplayUnitType.DUT_METERS_PER_KILONEWTON: return "MetersPerKilonewton";
case DisplayUnitType.DUT_METERS_PER_SECOND: return "MetersPerSecond";
case DisplayUnitType.DUT_MILLIAMPERES: return "Milliamperes";
case DisplayUnitType.DUT_MILLIMETERS: return "Millimeters";
case DisplayUnitType.DUT_MILLIMETERS_OF_MERCURY: return "MillimetersOfMercury";
case DisplayUnitType.DUT_MILLIVOLTS: return "Millivolts";
case DisplayUnitType.DUT_NEWTONS: return "Newtons";
case DisplayUnitType.DUT_NEWTONS_PER_METER: return "NewtonsPerMeter";
case DisplayUnitType.DUT_NEWTONS_PER_SQUARE_METER: return "NewtonsPerSqareMeter";
case DisplayUnitType.DUT_NEWTON_METERS: return "NewtonMeters";
case DisplayUnitType.DUT_NEWTON_METERS_PER_METER: return "NewtonMetersPerMeter";
case DisplayUnitType.DUT_PASCALS: return "Pascals";
case DisplayUnitType.DUT_PASCALS_PER_METER: return "PascalsPerMeter";
case DisplayUnitType.DUT_PASCAL_SECONDS: return "PascalSeconds";
case DisplayUnitType.DUT_PERCENTAGE: return "Percentage";
case DisplayUnitType.DUT_POUNDS_FORCE: return "PoundsForce";
case DisplayUnitType.DUT_POUNDS_FORCE_PER_CUBIC_FOOT: return "PoundsForcePerCubicFoot";
case DisplayUnitType.DUT_POUNDS_FORCE_PER_FOOT: return "PoundsForcePerFooT";
case DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_FOOT: return "PoundsForcePerSquareFoot";
case DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_INCH: return "PoundsForcePerSquareInch";
case DisplayUnitType.DUT_POUNDS_MASS_PER_CUBIC_FOOT: return "PoundsMassPerCubicFoot";
case DisplayUnitType.DUT_POUNDS_MASS_PER_CUBIC_INCH: return "PoundsMassPerCubicInch";
case DisplayUnitType.DUT_POUNDS_MASS_PER_FOOT_HOUR: return "PoundsMassPerFootHour";
case DisplayUnitType.DUT_POUNDS_MASS_PER_FOOT_SECOND: return "PoundsMassPerFootSecond";
case DisplayUnitType.DUT_POUND_FORCE_FEET: return "PoundForceFeet";
case DisplayUnitType.DUT_POUND_FORCE_FEET_PER_FOOT: return "PoundForceFeetPerFoot";
case DisplayUnitType.DUT_RANKINE: return "Rankine";
case DisplayUnitType.DUT_SQUARE_CENTIMETERS: return "SquareCentimeters";
case DisplayUnitType.DUT_SQUARE_FEET: return "SquareFeet";
case DisplayUnitType.DUT_SQUARE_FEET_PER_KIP: return "SquareFeetPerKip";
case DisplayUnitType.DUT_SQUARE_INCHES: return "SquareInches";
case DisplayUnitType.DUT_SQUARE_METERS: return "SquareMeterS";
case DisplayUnitType.DUT_SQUARE_METERS_PER_KILONEWTON: return "SqareMetersPerKilonewton";
case DisplayUnitType.DUT_SQUARE_MILLIMETERS: return "SquareMillimeters";
case DisplayUnitType.DUT_THERMS: return "Therms";
case DisplayUnitType.DUT_TONNES_FORCE: return "TonnesForce";
case DisplayUnitType.DUT_TONNES_FORCE_PER_METER: return "TonnesForcePerMeter";
case DisplayUnitType.DUT_TONNES_FORCE_PER_SQUARE_METER: return "TonnesForcePerSqareMeter";
case DisplayUnitType.DUT_TONNE_FORCE_METERS: return "TonneForceMeters";
case DisplayUnitType.DUT_TONNE_FORCE_METERS_PER_METER: return "TonneForceMetersPerMeter";
case DisplayUnitType.DUT_VOLTS: return "Volts";
case DisplayUnitType.DUT_VOLT_AMPERES: return "VoltAmperes";
case DisplayUnitType.DUT_WATTS: return "Watts";
case DisplayUnitType.DUT_WATTS_PER_SQUARE_FOOT: return "WattsPerSquareFoot";
case DisplayUnitType.DUT_WATTS_PER_SQUARE_METER: return "WattsPerSqareMeter";
default: return "";
}
}
/// <summary>
/// Get ratio between value in RevitAPI and value to display indicated by DisplayUnitType
/// </summary>
/// <param name="dut">
/// DisplayUnitType indicates display unit type
/// </param>
/// <returns>
/// Ratio
/// </returns>
private static double ImperialDutRatio(DisplayUnitType dut)
{
switch (dut)
{
case DisplayUnitType.DUT_ACRES: return 2.29568411386593E-05;
case DisplayUnitType.DUT_AMPERES: return 1;
case DisplayUnitType.DUT_ATMOSPHERES: return 3.23793722675857E-05;
case DisplayUnitType.DUT_BARS: return 3.28083989501312E-05;
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS: return 8.80550918411529E-05;
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS_PER_HOUR: return 0.316998330628151;
case DisplayUnitType.DUT_BRITISH_THERMAL_UNITS_PER_SECOND: return 8.80550918411529E-05;
case DisplayUnitType.DUT_CALORIES: return 0.0221895098882201;
case DisplayUnitType.DUT_CALORIES_PER_SECOND: return 0.0221895098882201;
case DisplayUnitType.DUT_CANDELAS: return 1;
case DisplayUnitType.DUT_CANDELAS_PER_SQUARE_METER: return 10.7639104167097;
case DisplayUnitType.DUT_CANDLEPOWER: return 1;
case DisplayUnitType.DUT_CELSIUS: return 1;
case DisplayUnitType.DUT_CENTIMETERS: return 30.48;
case DisplayUnitType.DUT_CENTIMETERS_PER_MINUTE: return 1828.8;
case DisplayUnitType.DUT_CENTIPOISES: return 3280.83989501312;
case DisplayUnitType.DUT_CUBIC_CENTIMETERS: return 28316.846592;
case DisplayUnitType.DUT_CUBIC_FEET: return 1;
case DisplayUnitType.DUT_CUBIC_FEET_PER_KIP: return 14593.9029372064;
case DisplayUnitType.DUT_CUBIC_FEET_PER_MINUTE: return 60;
case DisplayUnitType.DUT_CUBIC_INCHES: return 1728;
case DisplayUnitType.DUT_CUBIC_METERS: return 0.028316846592;
case DisplayUnitType.DUT_CUBIC_METERS_PER_HOUR: return 101.9406477312;
case DisplayUnitType.DUT_CUBIC_METERS_PER_KILONEWTON: return 92.90304;
case DisplayUnitType.DUT_CUBIC_METERS_PER_SECOND: return 0.028316846592;
case DisplayUnitType.DUT_CUBIC_MILLIMETERS: return 28316846.592;
case DisplayUnitType.DUT_CUBIC_YARDS: return 0.037037037037037;
case DisplayUnitType.DUT_CYCLES_PER_SECOND: return 1;
case DisplayUnitType.DUT_DECANEWTONS: return 0.03048;
case DisplayUnitType.DUT_DECANEWTONS_PER_METER: return 0.1;
case DisplayUnitType.DUT_DECANEWTONS_PER_SQUARE_METER: return 0.328083989501312;
case DisplayUnitType.DUT_DECANEWTON_METERS: return 0.009290304;
case DisplayUnitType.DUT_DECANEWTON_METERS_PER_METER: return 0.03048;
case DisplayUnitType.DUT_DECIMAL_DEGREES: return 57.2957795130823;
case DisplayUnitType.DUT_DECIMAL_FEET: return 1;
case DisplayUnitType.DUT_DECIMAL_INCHES: return 12;
case DisplayUnitType.DUT_DEGREES_AND_MINUTES: return 57.2957795130823;
case DisplayUnitType.DUT_FAHRENHEIT: return 1.8;
case DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES: return 1;
case DisplayUnitType.DUT_FEET_OF_WATER: return 0.00109764531546318;
case DisplayUnitType.DUT_FEET_OF_WATER_PER_100FT: return 0.109761336731934;
case DisplayUnitType.DUT_FEET_PER_KIP: return 14593.9029372064;
case DisplayUnitType.DUT_FEET_PER_MINUTE: return 60;
case DisplayUnitType.DUT_FEET_PER_SECOND: return 1;
case DisplayUnitType.DUT_FIXED: return 1;
case DisplayUnitType.DUT_FOOTCANDLES: return 1.0000000387136;
case DisplayUnitType.DUT_FOOTLAMBERTS: return 3.1415927449471;
case DisplayUnitType.DUT_FRACTIONAL_INCHES: return 12;
case DisplayUnitType.DUT_GALLONS_US: return 7.48051905367236;
case DisplayUnitType.DUT_GALLONS_US_PER_HOUR: return 26929.8685932205;
case DisplayUnitType.DUT_GALLONS_US_PER_MINUTE: return 448.831143220342;
case DisplayUnitType.DUT_GENERAL: return 1;
case DisplayUnitType.DUT_HECTARES: return 9.290304E-06;
case DisplayUnitType.DUT_HERTZ: return 1;
case DisplayUnitType.DUT_HORSEPOWER: return 0.00012458502883053;
case DisplayUnitType.DUT_INCHES_OF_MERCURY: return 0.000968831370233344;
case DisplayUnitType.DUT_INCHES_OF_WATER: return 0.0131845358262865;
case DisplayUnitType.DUT_INCHES_OF_WATER_PER_100FT: return 1.31845358262865;
case DisplayUnitType.DUT_INV_CELSIUS: return 1;
case DisplayUnitType.DUT_INV_FAHRENHEIT: return 0.555555555555556;
case DisplayUnitType.DUT_INV_KILONEWTONS: return 3280.83989501312;
case DisplayUnitType.DUT_INV_KIPS: return 14593.9029372064;
case DisplayUnitType.DUT_JOULES: return 0.09290304;
case DisplayUnitType.DUT_KELVIN: return 1;
case DisplayUnitType.DUT_KILOAMPERES: return 0.001;
case DisplayUnitType.DUT_KILOCALORIES: return 2.21895098882201E-05;
case DisplayUnitType.DUT_KILOCALORIES_PER_SECOND: return 2.21895098882201E-05;
case DisplayUnitType.DUT_KILOGRAMS_FORCE: return 0.0310810655372411;
case DisplayUnitType.DUT_KILOGRAMS_FORCE_PER_METER: return 0.101971999794098;
case DisplayUnitType.DUT_KILOGRAMS_FORCE_PER_SQUARE_METER: return 0.334553805098747;
case DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER: return 35.3146667214886;
case DisplayUnitType.DUT_KILOGRAM_FORCE_METERS: return 0.00947350877575109;
case DisplayUnitType.DUT_KILOGRAM_FORCE_METERS_PER_METER: return 0.0310810655372411;
case DisplayUnitType.DUT_KILONEWTONS: return 0.0003048;
case DisplayUnitType.DUT_KILONEWTONS_PER_CUBIC_METER: return 0.0107639104167097;
case DisplayUnitType.DUT_KILONEWTONS_PER_METER: return 0.001;
case DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER: return 0.00328083989501312;
case DisplayUnitType.DUT_KILONEWTON_METERS: return 9.290304E-05;
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE: return 9.290304E-05;
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE_PER_METER: return 0.0003048;
case DisplayUnitType.DUT_KILONEWTON_METERS_PER_METER: return 0.0003048;
case DisplayUnitType.DUT_KILOPASCALS: return 0.00328083989501312;
case DisplayUnitType.DUT_KILOVOLTS: return 9.290304E-05;
case DisplayUnitType.DUT_KILOVOLT_AMPERES: return 9.290304E-05;
case DisplayUnitType.DUT_KILOWATTS: return 9.290304E-05;
case DisplayUnitType.DUT_KILOWATT_HOURS: return 2.58064E-08;
case DisplayUnitType.DUT_KIPS: return 0.224808943099711;
case DisplayUnitType.DUT_KIPS_PER_CUBIC_FOOT: return 6.85217658567918E-05;
case DisplayUnitType.DUT_KIPS_PER_CUBIC_INCH: return 3.96537996856434E-08;
case DisplayUnitType.DUT_KIPS_PER_FOOT: return 6.85217658567918E-05;
case DisplayUnitType.DUT_KIPS_PER_INCH: return 5.71014715473265E-06;
case DisplayUnitType.DUT_KIPS_PER_SQUARE_FOOT: return 6.85217658567918E-05;
case DisplayUnitType.DUT_KIPS_PER_SQUARE_INCH: return 4.75845596227721E-07;
case DisplayUnitType.DUT_KIP_FEET: return 6.85217658567918E-05;
case DisplayUnitType.DUT_KIP_FEET_PER_DEGREE: return 2.08854342331501E-05;
case DisplayUnitType.DUT_KIP_FEET_PER_DEGREE_PER_FOOT: return 2.08854342331501E-05;
case DisplayUnitType.DUT_KIP_FEET_PER_FOOT: return 6.85217658567918E-05;
case DisplayUnitType.DUT_LITERS: return 28.316846592;
case DisplayUnitType.DUT_LITERS_PER_SECOND: return 28.316846592;
case DisplayUnitType.DUT_LUMENS: return 1;
case DisplayUnitType.DUT_LUX: return 10.7639104167097;
case DisplayUnitType.DUT_MEGANEWTONS: return 3.048E-07;
case DisplayUnitType.DUT_MEGANEWTONS_PER_METER: return 1E-06;
case DisplayUnitType.DUT_MEGANEWTONS_PER_SQUARE_METER: return 3.28083989501312E-06;
case DisplayUnitType.DUT_MEGANEWTON_METERS: return 9.290304E-08;
case DisplayUnitType.DUT_MEGANEWTON_METERS_PER_METER: return 3.048E-07;
case DisplayUnitType.DUT_MEGAPASCALS: return 3.28083989501312E-06;
case DisplayUnitType.DUT_METERS: return 0.3048;
case DisplayUnitType.DUT_METERS_CENTIMETERS: return 0.3048;
case DisplayUnitType.DUT_METERS_PER_KILONEWTON: return 1000;
case DisplayUnitType.DUT_METERS_PER_SECOND: return 0.3048;
case DisplayUnitType.DUT_MILLIAMPERES: return 1000;
case DisplayUnitType.DUT_MILLIMETERS: return 304.8;
case DisplayUnitType.DUT_MILLIMETERS_OF_MERCURY: return 0.0246083170946002;
case DisplayUnitType.DUT_MILLIVOLTS: return 92.90304;
case DisplayUnitType.DUT_NEWTONS: return 0.3048;
case DisplayUnitType.DUT_NEWTONS_PER_METER: return 1;
case DisplayUnitType.DUT_NEWTONS_PER_SQUARE_METER: return 3.28083989501312;
case DisplayUnitType.DUT_NEWTON_METERS: return 0.09290304;
case DisplayUnitType.DUT_NEWTON_METERS_PER_METER: return 0.3048;
case DisplayUnitType.DUT_PASCALS: return 3.28083989501312;
case DisplayUnitType.DUT_PASCALS_PER_METER: return 10.7639104167097;
case DisplayUnitType.DUT_PASCAL_SECONDS: return 3.28083989501312;
case DisplayUnitType.DUT_PERCENTAGE: return 100;
case DisplayUnitType.DUT_POUNDS_FORCE: return 224.80894309971;
case DisplayUnitType.DUT_POUNDS_FORCE_PER_CUBIC_FOOT: return 0.0685217658567918;
case DisplayUnitType.DUT_POUNDS_FORCE_PER_FOOT: return 0.0685217658567918;
case DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_FOOT: return 0.0685217658567917;
case DisplayUnitType.DUT_POUNDS_FORCE_PER_SQUARE_INCH: return 0.000475845616460903;
case DisplayUnitType.DUT_POUNDS_MASS_PER_CUBIC_FOOT: return 2.20462262184878;
case DisplayUnitType.DUT_POUNDS_MASS_PER_CUBIC_INCH: return 0.00127582327653286;
case DisplayUnitType.DUT_POUNDS_MASS_PER_FOOT_HOUR: return 7936.64143865559;
case DisplayUnitType.DUT_POUNDS_MASS_PER_FOOT_SECOND: return 2.20462262184878;
case DisplayUnitType.DUT_POUND_FORCE_FEET: return 0.0685217658567918;
case DisplayUnitType.DUT_POUND_FORCE_FEET_PER_FOOT: return 0.0685217658567918;
case DisplayUnitType.DUT_RANKINE: return 1.8;
case DisplayUnitType.DUT_SQUARE_CENTIMETERS: return 929.0304;
case DisplayUnitType.DUT_SQUARE_FEET: return 1;
case DisplayUnitType.DUT_SQUARE_FEET_PER_KIP: return 14593.9029372064;
case DisplayUnitType.DUT_SQUARE_INCHES: return 144;
case DisplayUnitType.DUT_SQUARE_METERS: return 0.09290304;
case DisplayUnitType.DUT_SQUARE_METERS_PER_KILONEWTON: return 304.8;
case DisplayUnitType.DUT_SQUARE_MILLIMETERS: return 92903.04;
case DisplayUnitType.DUT_THERMS: return 8.80547457016663E-10;
case DisplayUnitType.DUT_TONNES_FORCE: return 3.10810655372411E-05;
case DisplayUnitType.DUT_TONNES_FORCE_PER_METER: return 0.000101971999794098;
case DisplayUnitType.DUT_TONNES_FORCE_PER_SQUARE_METER: return 0.000334553805098747;
case DisplayUnitType.DUT_TONNE_FORCE_METERS: return 9.47350877575109E-06;
case DisplayUnitType.DUT_TONNE_FORCE_METERS_PER_METER: return 3.10810655372411E-05;
case DisplayUnitType.DUT_VOLTS: return 0.09290304;
case DisplayUnitType.DUT_VOLT_AMPERES: return 0.09290304;
case DisplayUnitType.DUT_WATTS: return 0.09290304;
case DisplayUnitType.DUT_WATTS_PER_SQUARE_FOOT: return 0.09290304;
case DisplayUnitType.DUT_WATTS_PER_SQUARE_METER: return 1;
default: return 1;
}
}
#endregion
}
}
url:http://greatverve.cnblogs.com/p/revit-api-UnitConvert.html