SetUnitType Method


Sets the type of units for the field.

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

Syntax

C#
public FieldBuilder SetUnitType(
	UnitType units
)
Visual Basic
Public Function SetUnitType ( _
	units As UnitType _
) As FieldBuilder
Visual C++
public:
FieldBuilder^ SetUnitType(
	UnitType units
)

Parameters

units
Type: Autodesk.Revit.DB UnitType
Units type value to be set

Return Value

The FieldBuilder object may be used to add more details to the field.

Remarks

All floating-point fields (float, double, XYZ, UV and containers of these values) will be internally stored in the metric system. You must specify the unit type (length, temperature, etc.) via this method for such fields. Conversely, all other field types may not have units. Do not call this method on those fields.

The dimension of the field (3 for XYZ, 2 for UV, arbitrary for array) extends the power of the unit type by allowing you to represent vectors of values of specific units. Each component will be converted independently. Using vectors to represent multiple independent values will work efficiently, but make sure the documentation is adequate.

The Get and Set methods will need you to specify the units in which your program works, as a DisplayUnitType. These units must be compatible with the UnitType. Revit will convert the stored values from/to the units you specify.

Use UT_Custom and DUT_CUSTOM to explicitly disable conversions for a field.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentOutOfRangeException A value passed for an enumeration argument is not a member of that enumeration
Autodesk.Revit.Exceptions InvalidOperationException The SchemaBuilder has already finished building the Schema. -or- The field type does not utilize unit conversions.

See Also