---
title: Calculated values
summary: Use the quantities, bounding boxes and consistency flags BIM.works derives from the geometry itself, and compare them with what the authoring tool exported.
order: 70
terms: [bql, quantity, quantity-set]
see-also: [tutorials/bql/units-and-parameters, tutorials/bql/surveying-a-model, reference/bql/calculated-values]
---

# Calculated values

Everything you have queried so far was in the file: an attribute, a property, a quantity somebody exported. BIM.works also computes values from the geometry of each object, and those exist whether the authoring tool wrote them or not. They live under `calculated.` and under `aabb.`.

## calculated.quantity

The derived quantities are volumes, areas, perimeters — one path per quantity, no set name, because BIM.works computes them itself:

```bql {#calculated-quantity}
GET qid, attribute.LongName, calculated.quantity.floorArea UNIT m2, calculated.quantity.volume UNIT m3
WHERE type = IFCSPACE
```

`floorArea` is the floor area of a space or a horizontal element, `volume` the volume of the object's geometry, `perimeter` the perimeter of its footprint, `area` its total surface area. They are computed from the same geometry the viewer draws, so a space whose boundaries do not close gets no value rather than a wrong one. The full list is on [[bql:calculated-values]].

## The bounding box

`aabb` is the axis-aligned bounding box of the object, in model coordinates: `aabb.width`, `aabb.depth`, `aabb.height`, and the six sides `aabb.minx`, `aabb.maxx`, `aabb.miny`, `aabb.maxy`, `aabb.minz`, `aabb.maxz`. It is the cheapest way to ask a geometric question, and it needs no property to be present:

```bql {#aabb}
GET qid, attribute.Name, aabb.height WHERE type = IFCDOOR ORDER BY aabb.height DESC LIMIT 5 USING LENGTH_UNIT = m
```

A bounding box is not the object: a diagonal beam has a box far larger than itself. When that matters, the oriented box (`calculated.obb.*`) and the spatial predicates of [[bql:spatial-and-advanced]] are the tools.

## Comparing the file with the geometry

Because both the exported and the computed quantity are queryable, one condition compares them — which is how a model is checked for quantities that no longer match the shapes:

```bql {#within}
GET qid, attribute.Name, quantity.*.NetVolume, calculated.quantity.volume
WHERE type = IFCWALL AND quantity.*.NetVolume != calculated.quantity.volume WITHIN 2 %
USING VOLUME_UNIT = m3
```

`WITHIN` turns an exact comparison into a tolerant one: `= … WITHIN 2 %` is "equal to within two per cent", and with `!=` in front it selects the objects that differ by more than that. A tolerance may also be absolute (`WITHIN 0.05 m3`). Arithmetic works on both sides, so `ABS(a - b)` and `a > b * 1.1` are conditions too ([[bql:where#within]]).

On Schependomlaan that query returns nothing, which is the answer you want: all 877 walls that carry a `NetVolume` agree with their geometry to within one per cent. Run it on a model that has been edited by hand for a while and it stops being empty.

```tip
`calculated.consistency.watertight`, `.manifold` and `.bwOpenEdges` describe the mesh itself, and `calculated.geometry.counts.triangles` how heavy it is. They are the fastest way to find the objects that will give a viewer or an export trouble: 602 objects of the demo model are not watertight, 64 of them walls.
```

## Your turn

```lesson {#lesson-1}
goal: List every space with its LongName and the floor area BIM.works computes from the geometry, in square metres.
show: table
check: values
starter: |
  GET qid, attribute.LongName WHERE type = IFCSPACE
hints: |
  - The path is calculated.quantity.floorArea; there is no set name.
  - UNIT m2 converts the column to square metres.
solution: |
  GET qid, attribute.LongName, calculated.quantity.floorArea UNIT m2 WHERE type = IFCSPACE
accept: |
  - GET qid, attribute.LongName, calculated.quantity.floorArea WHERE type = IFCSPACE USING AREA_UNIT = m2
```

```lesson {#lesson-2}
goal: Show the five highest doors of the model in the viewer, with their name and their height in metres, highest first.
show: viewer
check: sequence
starter: |
  GET qid, attribute.Name, aabb.height WHERE type = IFCDOOR
hints: |
  - The height of the bounding box is aabb.height.
  - ORDER BY … DESC sorts from large to small, and LIMIT cuts the sorted result.
  - USING LENGTH_UNIT = m converts the height to metres.
solution: |
  GET qid, attribute.Name, aabb.height WHERE type = IFCDOOR ORDER BY aabb.height DESC LIMIT 5 USING LENGTH_UNIT = m
accept: |
  - GET qid, aabb.height, attribute.Name WHERE type = IFCDOOR ORDER BY aabb.height DESC LIMIT 5 USING LENGTH_UNIT = m
```

Five doors, coloured in the model: with the view framed on them you can see at once that the highest "doors" of this model are frames — `stelkozijn`, 2.82 m — and not the front door.

```lesson {#lesson-3}
goal: List the walls whose geometry is not watertight, with their name.
show: table
check: objects
starter: |
  GET qid, attribute.Name WHERE type = IFCWALL
hints: |
  - The flag is calculated.consistency.watertight.
  - It is a boolean, so compare it with false.
solution: |
  GET qid, attribute.Name WHERE type = IFCWALL AND calculated.consistency.watertight = false
accept: |
  - GET qid, attribute.Name WHERE calculated.consistency.watertight = false AND type = IFCWALL
```

64 of the 934 walls have a mesh with holes in it. That is the query to run before you blame a viewer or an export for a wall that looks wrong: the geometry was already open in the file.

## You can now

- Read the quantities BIM.works derives from the geometry, whatever the file contains.
- Use the bounding box of an object in `GET`, in `WHERE` and as a sort key.
- Compare two features with each other, with a tolerance.

Next: [Surveying a model](surveying-a-model.md), the queries you run on a model you have never seen.
