# Units

The Units object is used to convert values from one unit to another. See the Unit Constants Reference for a full list of the Unit Groups and Unit Ids. Note: All Network Result property values are stored in SI units.
Function/Property | Description
Convert(FromUnitNameOrId, ToUnitNameOrId: Variant; Value: Float): Float | Convert Value from FromUnitNameOrId to ToUnitNameOrId. This routine assumes that the Units belong to the same Unit Group.
CrossConvert(UnitGroupNameOrId, FromUnitNameOrId, ToUnitNameOrId: Variant; Value, Rho: Float): Float | Convert Value from FromUnitNameOrId to ToUnitNameOrId using Rho.
GetUnitGroupId(UnitId: Integer): Integer | Returns the Unit Group Id that UnitId belongs to.
GetUnitId(Name: String): Integer | Returns the Unit Id associated with Name.
GetUnitIds(GroupId: Integer; UnitIds: IntegerArray): Integer |
GetUnitName(UnitId: Integer): String | Returns the Name associated with UnitId.
GetUnits(GroupId: Integer; Units: TRecordList): Integer | Fills Units with all the unit records (including Id, Name, and ConversionFactor) for the specified GroupId. Returns the count.
GetGroupId(Name: string): Integer | Returns the Group Id associated with Name.
GetGroupIds(GroupIds: IntegerArray): Integer | Fills GroupIds with the Ids of all available unit groups.
GetGroupName(GroupId: Integer): string | Returns the Name associated with GroupId.
GetGroups(Groups: TRecordList): Integer | Fills Groups with the records (Id, Name, UnitCount) of all available unit groups.
Example: Display the names of all the units for unit group 20 (Density). var uList: TRecordList; u: TRecord; begin Units.GetUnits(20, uList); for i := 0 to uList.Count - 1 do begin u := uList[i]; Output.Add(u['Name']); end; end; Example: This example gets the Boundary Pressure value of the Node with Id 1, and converts it from the entered Pressure Unit to bar g. Output.Clear; Node1 := Network.GetElement(1); Pressure := Node1.Get('BoundaryPressure'); PressureUnitId := Node1.Get('BoundaryPressureUnit'); PressureBarG := Units.Convert(PressureUnitId, 'bar g', Pressure); Output.Add(PressureBarG);