Skip to content

Instantly share code, notes, and snippets.

@imAliAsad
Created January 21, 2018 08:01
Show Gist options
  • Save imAliAsad/01893377dedef31b1e059a6241fc9b22 to your computer and use it in GitHub Desktop.
Save imAliAsad/01893377dedef31b1e059a6241fc9b22 to your computer and use it in GitHub Desktop.
Extract or read Revit family parameter data and convert its internal ( Imperial ) unit into the metrics unit
/// <summary>
/// Extract all family type properties data
/// </summary>
/// <param name="app"></param>
private MultiValueDictionary<string, Tuple<string, string>> ExtractFamilyParameterInfo(Application app)
{
//Open Revit Family File in a separate document
var doc = app.OpenDocumentFile(FamilyPath);
//Get the familyManager instance from the open document
var familyManager = doc.FamilyManager;
int totalParams = familyManager.Parameters.Size;
Dictionary<string, FamilyParameter> familyparameters = new Dictionary<string, FamilyParameter>(totalParams);
foreach (FamilyParameter familyParameter in familyManager.Parameters)
{
string name = familyParameter.Definition.Name;
familyparameters.Add(name, familyParameter);
}
List<string> keys = new List<string>(familyparameters.Keys);
keys.Sort();
/// List down all familytypes of a family
foreach (FamilyType familytype in familyManager.Types)
{
string name = familytype.Name;
MultiValueDictionary<string, Tuple<string, string>> Parameters = new MultiValueDictionary<string, Tuple<string, string>>();
foreach (string key in keys)
{
// Key is parameter name, e.g: Angle, Assembly Code etc
FamilyParameter familyparameter = familyparameters[key];
var definition = familyparameter.Definition;
string ParameterGroupid = LabelUtils.GetLabelFor(definition.ParameterGroup);
if (familytype.HasValue(familyparameter))
{
// Reading type's parameter value
string value = FamilyParamValueString(familytype, familyparameter, doc);
//store parameter information along with its group
Parameters.Add(ParameterGroupid, new Tuple<string, string>(key, value));
}
}
}
return Parameters;
}
#endregion
static string FamilyParamValueString(FamilyType familytype, FamilyParameter familyparam, Document doc)
{
string value = familytype.AsValueString(familyparam);
switch (familyparam.StorageType)
{
case StorageType.Double:
value = Util.RealString(
(double)familytype.AsDouble(familyparam));
value = UnitConvertor.ConvertInternalUnitDouble(double.Parse(value), familyparam.Definition.ParameterType);
break;
case StorageType.ElementId:
ElementId id = familytype.AsElementId(familyparam);
Element e = doc.GetElement(id);
value = Util.ElementDescription(e);
break;
case StorageType.Integer:
value = familytype.AsInteger(familyparam).ToString();
break;
case StorageType.String:
value = familytype.AsString(familyparam);
break;
}
return value;
}
public static class UnitConvertor
{
public static string ConvertInternalUnitToMetricUnit(double value, ParameterType parametertype)
{
switch (parametertype)
{
#region Following units has values in Double
case ParameterType.ElectricalLuminousIntensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CANDELAS);
return $"{Util.RealString(value)} cd";
case ParameterType.Angle:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_DECIMAL_DEGREES);
return $"{Util.RealString(value)} °";
case ParameterType.ElectricalCurrent:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_AMPERES);
return $"{Util.RealString(value)} A";
case ParameterType.UnitWeight:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_CUBIC_METER);
return $"{Util.RealString(value)} kN/m³";
case ParameterType.Currency:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CURRENCY);
return $"{Util.RealString(value)}";
case ParameterType.Area:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_METERS);
return $"{Util.RealString(value)} m²";
case ParameterType.Volume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CUBIC_METERS);
return $"{Util.RealString(value)} m³";
case ParameterType.Number:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_GENERAL);
return $"{Util.RealString(value)}";
case ParameterType.Length:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ElectricalPotential:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_VOLTS);
return $"{Util.RealString(value)} V";
case ParameterType.Stress:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MEGAPASCALS);
return $"{Util.RealString(value)} MPa";
case ParameterType.Slope:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PERCENTAGE);
return $"{Util.RealString(value)} %";
case ParameterType.Energy:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOJOULES);
return $"{Util.RealString(value)} KJ";
case ParameterType.HVACDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER);
return $"{Util.RealString(value)} kg/m³";
case ParameterType.HVACEnergy:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_JOULES);
return $"{Util.RealString(value)} J";
case ParameterType.HVACFriction:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCALS_PER_METER);
return $"{Util.RealString(value)} Pa/m";
case ParameterType.HVACPower:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.HVACPowerDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_SQUARE_METER);
return $"{Util.RealString(value)} W/m²";
case ParameterType.HVACPressure:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCALS);
return $"{Util.RealString(value)} Pa";
case ParameterType.HVACTemperature:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.HVACVelocity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_METERS_PER_SECOND);
return $"{Util.RealString(value)} m/s";
case ParameterType.HVACAirflow:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS_PER_SECOND);
return $"{Util.RealString(value)} L/s";
case ParameterType.HVACDuctSize:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.HVACCrossSection:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_MILLIMETERS);
return $"{Util.RealString(value)} mm²";
case ParameterType.HVACHeatGain:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.ElectricalFrequency:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_HERTZ);
return $"{Util.RealString(value)} Hz";
case ParameterType.ElectricalIlluminance:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LUX);
return $"{Util.RealString(value)} lx";
case ParameterType.ElectricalLuminance:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CANDELAS_PER_SQUARE_METER);
return $"{Util.RealString(value)} cd/m²";
case ParameterType.ElectricalLuminousFlux:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LUMENS);
return $"{Util.RealString(value)} lm";
case ParameterType.ElectricalEfficacy:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LUMENS_PER_WATT);
return $"{Util.RealString(value)} lm/W";
case ParameterType.ElectricalWattage:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.ColorTemperature:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KELVIN);
return $"{Util.RealString(value)} K";
case ParameterType.ElectricalPower:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.HVACRoughness:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ElectricalApparentPower:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_VOLT_AMPERES);
return $"{Util.RealString(value)} VA";
case ParameterType.ElectricalPowerDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_SQUARE_METER);
return $"{Util.RealString(value)} W/m²";
case ParameterType.PipingDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER);
return $"{Util.RealString(value)} kg/m³";
case ParameterType.PipingFlow:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS_PER_SECOND);
return $"{Util.RealString(value)} L/s";
case ParameterType.PipingFriction:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCALS_PER_METER);
return $"{Util.RealString(value)} Pa/m";
case ParameterType.PipingPressure:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCALS);
return $"{Util.RealString(value)} Pa";
case ParameterType.PipingTemperature:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.PipingVelocity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_METERS_PER_SECOND);
return $"{Util.RealString(value)} m/s";
case ParameterType.PipingViscosity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCAL_SECONDS);
return $"{Util.RealString(value)} Pa-s";
case ParameterType.PipeSize:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.PipingRoughness:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.PipingVolume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS);
return $"{Util.RealString(value)} L";
case ParameterType.HVACViscosity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PASCAL_SECONDS);
return $"{Util.RealString(value)} Pa-s";
case ParameterType.HVACCoefficientOfHeatTransfer:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_SQUARE_METER_KELVIN);
return $"{Util.RealString(value)} W/(m²•K)";
case ParameterType.HVACThermalResistance:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_METER_KELVIN_PER_WATT);
return $"{Util.RealString(value)} (m²•K)/W";
case ParameterType.HVACThermalMass:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOJOULES_PER_KELVIN);
return $"{Util.RealString(value)} kJ/K";
case ParameterType.HVACThermalConductivity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_METER_KELVIN);
return $"{Util.RealString(value)} W/(m•K)";
case ParameterType.HVACSpecificHeat:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_JOULES_PER_GRAM_CELSIUS);
return $"{Util.RealString(value)} J/(g•°C)";
case ParameterType.HVACSpecificHeatOfVaporization:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_JOULES_PER_GRAM);
return $"{Util.RealString(value)} J/g";
case ParameterType.HVACPermeability:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_NANOGRAMS_PER_PASCAL_SECOND_SQUARE_METER);
return $"{Util.RealString(value)} ng/(Pa•s•m²)";
case ParameterType.ElectricalResistivity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_OHM_METERS);
return $"{Util.RealString(value)} ohm•m";
case ParameterType.HVACCoolingLoadDividedByVolume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_CUBIC_METER);
return $"{Util.RealString(value)} W/m³";
case ParameterType.HVACHeatingLoadDividedByVolume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_CUBIC_METER);
return $"{Util.RealString(value)} W/m³";
case ParameterType.HVACAirflowDividedByVolume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS_PER_SECOND_CUBIC_METER);
return $"{Util.RealString(value)} L/(s•m³)";
case ParameterType.HVACAirflowDividedByCoolingLoad:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS_PER_SECOND_KILOWATTS);
return $"{Util.RealString(value)} L/(s•kW)";
case ParameterType.WireSize:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.HVACSlope:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PERCENTAGE);
return $"{Util.RealString(value)} %";
case ParameterType.HVACAreaDividedByHeatingLoad:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_METERS_PER_KILOWATTS);
return $"{Util.RealString(value)} m²/kW";
case ParameterType.HVACCoolingLoadDividedByArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_SQUARE_METER);
return $"{Util.RealString(value)} W/m²";
case ParameterType.HVACCoolingLoad:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.HVACHeatingLoadDividedByArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS_PER_SQUARE_METER);
return $"{Util.RealString(value)} W/m²";
case ParameterType.HVACAirflowDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_LITERS_PER_SECOND_SQUARE_METER);
return $"{Util.RealString(value)} L/(s•m²)";
case ParameterType.HVACFactor:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PERCENTAGE);
return $"{Util.RealString(value)} %";
case ParameterType.HVACAreaDividedByCoolingLoad:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_METERS_PER_KILOWATTS);
return $"{Util.RealString(value)} m²/kW";
case ParameterType.HVACHeatingLoad:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_WATTS);
return $"{Util.RealString(value)} W";
case ParameterType.Force:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS);
return $"{Util.RealString(value)} KN";
case ParameterType.LinearForce:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_METER);
return $"{Util.RealString(value)} kN/m";
case ParameterType.AreaForce:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER);
return $"{Util.RealString(value)} kN/m²";
case ParameterType.Moment:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTON_METERS);
return $"{Util.RealString(value)} kN-m";
case ParameterType.ThermalExpansion:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_INV_CELSIUS);
return $"{Util.RealString(value)} 1/°C";
case ParameterType.LinearMoment:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTON_METERS_PER_METER);
return $"{Util.RealString(value)} kN-m/m";
case ParameterType.ForcePerLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_METER);
return $"{Util.RealString(value)} kN/m";
case ParameterType.ForceLengthPerAngle:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE);
return $"{Util.RealString(value)} kN-m/°";
case ParameterType.LinearForcePerLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_SQUARE_METER);
return $"{Util.RealString(value)} kN/m²";
case ParameterType.LinearForceLengthPerAngle:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTON_METERS_PER_DEGREE_PER_METER);
return $"{Util.RealString(value)} kN-m/°/m";
case ParameterType.AreaForcePerLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS_PER_CUBIC_METER);
return $"{Util.RealString(value)} kN/m³";
case ParameterType.PipingSlope:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PERCENTAGE);
return $"{Util.RealString(value)} %";
case ParameterType.ElectricalTemperature:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.ElectricalCableTraySize:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ElectricalConduitSize:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ReinforcementVolume:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CUBIC_CENTIMETERS);
return $"{Util.RealString(value)} cm³";
case ParameterType.ReinforcementLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ElectricalDemandFactor:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_PERCENTAGE);
return $"{Util.RealString(value)} %";
case ParameterType.HVACDuctInsulationThickness:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.HVACDuctLiningThickness:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.PipeInsulationThickness:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.Acceleration:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_METERS_PER_SECOND_SQUARED);
return $"{Util.RealString(value)} m/s²";
case ParameterType.BarDiameter:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.CrackWidth:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.StructuralFrequency:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_HERTZ);
return $"{Util.RealString(value)} Hz";
case ParameterType.Mass:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_MASS);
return $"{Util.RealString(value)} kg";
case ParameterType.MomentOfInertia:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CENTIMETERS_TO_THE_FOURTH_POWER);
return $"{Util.RealString(value)} cm4";
case ParameterType.SurfaceArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_METERS_PER_METER);
return $"{Util.RealString(value)} m²/m";
case ParameterType.Period:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SECONDS);
return $"{Util.RealString(value)} s";
case ParameterType.Pulsation:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_RADIANS_PER_SECOND);
return $"{Util.RealString(value)} rad/s";
case ParameterType.ReinforcementArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_CENTIMETERS);
return $"{Util.RealString(value)} cm²";
case ParameterType.ReinforcementAreaPerUnitLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_CENTIMETERS_PER_METER);
return $"{Util.RealString(value)} cm²/m";
case ParameterType.ReinforcementCover:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.ReinforcementSpacing:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.Rotation:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_RADIANS);
return $"{Util.RealString(value)} rad";
case ParameterType.SectionArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_SQUARE_CENTIMETERS);
return $"{Util.RealString(value)} cm²";
case ParameterType.SectionDimension:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CENTIMETERS);
return $"{Util.RealString(value)} cm";
case ParameterType.SectionModulus:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CUBIC_CENTIMETERS);
return $"{Util.RealString(value)} cm³";
case ParameterType.SectionProperty:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CENTIMETERS);
return $"{Util.RealString(value)} cm";
case ParameterType.StructuralVelocity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_METERS_PER_SECOND);
return $"{Util.RealString(value)} m/s";
case ParameterType.WarpingConstant:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CENTIMETERS_TO_THE_SIXTH_POWER);
return $"{Util.RealString(value)} cm6";
case ParameterType.Weight:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILONEWTONS);
return $"{Util.RealString(value)} kN";
case ParameterType.WeightPerUnitLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_FORCE_PER_METER);
return $"{Util.RealString(value)} kgf/m";
case ParameterType.MassDensity:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_PER_CUBIC_METER);
return $"{Util.RealString(value)} kg/m³";
case ParameterType.MassPerUnitArea:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_MASS_PER_SQUARE_METER);
return $"{Util.RealString(value)} kg/m²";
case ParameterType.PipeDimension:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_MILLIMETERS);
return $"{Util.RealString(value)} mm";
case ParameterType.PipeMass:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_MASS);
return $"{Util.RealString(value)} Kg";
case ParameterType.PipeMassPerUnitLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_MASS_PER_METER);
return $"{Util.RealString(value)} kg/m";
case ParameterType.DisplacementDeflection:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CENTIMETERS);
return $"{Util.RealString(value)} cm";
case ParameterType.MassPerUnitLength:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_KILOGRAMS_MASS_PER_METER);
return $"{Util.RealString(value)} kg/m";
case ParameterType.HVACTemperatureDifference:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.PipingTemperatureDifference:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.ElectricalTemperatureDifference:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_CELSIUS);
return $"{Util.RealString(value)} °C";
case ParameterType.NumberOfPoles:
value = UnitUtils.ConvertFromInternalUnits(value, DisplayUnitType.DUT_GENERAL);
return $"{Util.RealString(value)} ";
#endregion
#region Following paramereter type can't be converted to any unit
case ParameterType.Invalid:
case ParameterType.Text:
case ParameterType.Integer:
case ParameterType.URL:
case ParameterType.Material:
case ParameterType.YesNo:
case ParameterType.FixtureUnit:
case ParameterType.FamilyType:
case ParameterType.LoadClassification:
case ParameterType.Image:
case ParameterType.MultilineText:
break;
#endregion
default:
break;
}
return value.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment