单位转换
Revit内部基本单位是英尺,我们需要进行单位转换
Revit和相比
单位的表示,由DisplayUnitType枚举字段表示,变成了UnitTypeId静态类的只读属性。
DisplayUnitType(int)——>UnitTypeId(ForgeTypeId)
public static double Convert(double value, ForgeTypeId currentUnitTypeId, ForgeTypeId desiredUnitTypeId);public static double ConvertFromInternalUnits(double value, ForgeTypeId unitTypeId);
//英尺到米double d = UnitUtils.Convert(value, DisplayUnitType.DUT_DECIMAL_FEET, DisplayUnitType.DUT_METERS);//英尺到毫米double d = UnitUtils.Convert(value,DisplayUnitType.DUT_DECIMAL_FEET,DisplayUnitType.DUT_MILLIMETERS);//平方英尺到平方米double d = UnitUtils.Convert(value, DisplayUnitType.DUT_SQUARE_FEET, DisplayUnitType.DUT_SQUARE_METERS);//立方英尺到立方米double d = UnitUtils.Convert(value, DisplayUnitType.DUT_CUBIC_FEET, DisplayUnitType.DUT_CUBIC_METERS);
使用UnitTypeId代替DisplayUnitType。
以下是代码片段:
//var load = UnitUtils.ConvertFromInternalUnits(// parameterValue.Value,// DisplayUnitType.DUT_VOLT_AMPERES ); // var load = UnitUtils.ConvertFromInternalUnits(parameterValue.Value,UnitTypeId.VoltAmperes ); //