Format Method


Formats a number with units into a string based on the units formatting settings for a document.

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

Syntax

C#
[ObsoleteAttribute("This method is deprecated in Revit 2015.  Use UnitFormatUtils.Format() instead.")]
public static string Format(
	Document document,
	UnitType unitType,
	double value
)
Visual Basic
<ObsoleteAttribute("This method is deprecated in Revit 2015.  Use UnitFormatUtils.Format() instead.")> _
Public Shared Function Format ( _
	document As Document, _
	unitType As UnitType, _
	value As Double _
) As String
Visual C++
[ObsoleteAttribute(L"This method is deprecated in Revit 2015.  Use UnitFormatUtils.Format() instead.")]
public:
static String^ Format(
	Document^ document, 
	UnitType unitType, 
	double value
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document whose Units object will be used for the units formatting settings.
unitType
Type: Autodesk.Revit.DB UnitType
The unit type of the value to format.
value
Type: System Double
The value to format, in Revit's internal units.

Return Value

The formatted string.

Remarks

For additional formatting options, see UnitFormatUtils.Format() This method is equivalent to calling UnitFormatUtils.Format() with the Units object obtained from Document.GetUnits() and with maxAccuracy and forEditing set to false.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException unitType is an invalid unit type. See UnitUtils.IsValidUnitType() and UnitUtils.GetValidUnitTypes(). -or- The given value for value is not finite
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions ArgumentOutOfRangeException A value passed for an enumeration argument is not a member of that enumeration
Autodesk.Revit.Exceptions InvalidOperationException The document is in failure mode: an operation has failed, and Revit requires the user to either cancel the operation or fix the problem (usually by deleting certain elements).

See Also