UNIT

Per-feature unit conversion in GET — the UNIT clause, the length, area, volume, mass and temperature units, unit literals in expressions, and how converted values appear in the result.

UNIT <unit> after a GET item converts that one numeric value to the given unit. It applies to a feature or an arithmetic expression, never to an aggregate, and it precedes the AS alias. To convert every value of a dimension at once, use USING and parameters.

Syntax#

Text#
GET <feature or expression> UNIT <unit> [AS <alias>]
BQL#
GET qid, quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2 AS SideArea WHERE type = IFCWALL
BQL#
GET qid, quantity.Qto_WallBaseQuantities.NetVolume / 2 UNIT m3 AS Half WHERE type = IFCWALL

Units#

Dimension Units
Length mm cm dm m km in ft yd mi
Area mm2 cm2 dm2 m2 km2 in2 ft2 yd2 ac mi2
Volume mm3 cm3 dm3 m3 in3 ft3 yd3 l
Mass mg cg g kg
Temperature dc (degrees Celsius)

in (inch) is lower case; upper-case IN is the membership operator. A litre is a cubic decimetre. The unit's dimension has to match the value's: an area converted to mm gives no value (the column is null). USING takes the same units (using#units).

Unit literals#

The same unit names attach to numbers anywhere a number is written — in comparisons, in arithmetic, in BETWEEN and BIN, in tolerances and in the geometry functions: > 2.4 m, BETWEEN (1 m, 2 m), WITHIN 5 mm, BIN(aabb.height, 500 mm). A number with a unit is converted before it is compared. A number without one is not converted, and what it means depends on how the condition is answered:

  • most comparisons on attributes, properties and quantities are answered from the value index, which holds numbers in canonical units: lengths in mm, areas in m², volumes in m³, masses in kg. On a model in metres, quantity.Qto_WallBaseQuantities.Height > 2.5 selects walls higher than 2.5 mm;
  • the other comparisons use the value as stored, in the model's unit.

So write the unit: > 2.5 m means the same in both cases. Against an arithmetic expression a bare number other than 0 matches nothing; 0 is a zero of any dimension. geometry:clearance, the nav: functions and AGENT read a bare length as millimetres (Spatial and advanced). The validator warns when a unit it does not know is used.

BQL#
GET qid, quantity.Qto_DoorBaseQuantities.Width UNIT mm WHERE type = IFCDOOR AND quantity.Qto_DoorBaseQuantities.Width > 1.05 m

What the result shows#

A converted value is a plain number leaf with the target unit, without the feature's metadata: {"type": "double", "value": 12.5, "unit": "SQUARED_METER"}, keyed by the item's whole text ("quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2") whatever its alias. An explicit UNIT overrides a USING clause for that item, and the item is not annotated with the original unit; a USING conversion is, see using#result.

Used in#