ConvertFromInternalUnits Method


Converts a value from Revit's internal units to a given display unit.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2014

Syntax

C#
public static double ConvertFromInternalUnits(
	double value,
	DisplayUnitType displayUnit
)
Visual Basic
Public Shared Function ConvertFromInternalUnits ( _
	value As Double, _
	displayUnit As DisplayUnitType _
) As Double
Visual C++
public:
static double ConvertFromInternalUnits(
	double value, 
	DisplayUnitType displayUnit
)

Parameters

value
Type: System Double
The value to convert.
displayUnit
Type: Autodesk.Revit.DB DisplayUnitType
The desired display unit.

Return Value

The converted value.

Examples

Copy C#
double GetYieldStressInKsi(Material material)
{
    double minYieldStress = 0;
    // Get the structural asset for the material
    ElementId strucAssetId = material.StructuralAssetId;
    if (strucAssetId != ElementId.InvalidElementId)
    {
        PropertySetElement pse = material.Document.GetElement(strucAssetId) as PropertySetElement;
        if (pse != null)
        {
            StructuralAsset asset = pse.GetStructuralAsset();

            // Get the min yield stress and convert to ksi
            double minYieldStressInRevitUnits = asset.MinimumYieldStress;
            minYieldStress = UnitUtils.ConvertFromInternalUnits(minYieldStressInRevitUnits, 
                DisplayUnitType.DUT_KIPS_PER_SQUARE_INCH);
        }
    }

    return minYieldStress;
}
Copy VB.NET
Private Function GetYieldStressInKsi(material As Material) As Double
    Dim minYieldStress As Double = 0
    ' Get the structural asset for the material
    Dim strucAssetId As ElementId = material.StructuralAssetId
    If strucAssetId <> ElementId.InvalidElementId Then
        Dim pse As PropertySetElement = TryCast(material.Document.GetElement(strucAssetId), PropertySetElement)
        If pse IsNot Nothing Then
            Dim asset As StructuralAsset = pse.GetStructuralAsset()

            ' Get the min yield stress and convert to ksi
            Dim minYieldStressInRevitUnits As Double = asset.MinimumYieldStress
            minYieldStress = UnitUtils.ConvertFromInternalUnits(minYieldStressInRevitUnits, DisplayUnitType.DUT_KIPS_PER_SQUARE_INCH)
        End If
    End If

    Return minYieldStress
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The given value for value is not finite -or- displayUnit is an invalid display unit. See UnitUtils.IsValidDisplayUnit(DisplayUnitType) and UnitUtils.GetValidDisplayUnits().
Autodesk.Revit.Exceptions ArgumentOutOfRangeException A value passed for an enumeration argument is not a member of that enumeration

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →