Tutorial·Learn BQL by doing

Calculated values

Use the quantities, bounding boxes and consistency flags BIM.works derives from the geometry itself, and compare them with what the authoring tool exported.

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#
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 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#
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 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#
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 (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#

GoalDemo model · Schependomlaan
List every space with its LongName and the floor area BIM.works computes from the geometry, in square metres.
GET qid, attribute.LongName WHERE type = IFCSPACE
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. The path is calculated.quantity.floorArea; there is no set name.
  2. UNIT m2 converts the column to square metres.
Show solution
GET qid, attribute.LongName, calculated.quantity.floorArea UNIT m2 WHERE type = IFCSPACE
Also accepted
GET qid, attribute.LongName, calculated.quantity.floorArea WHERE type = IFCSPACE USING AREA_UNIT = m2
GoalDemo model · Schependomlaan
Show the five highest doors of the model in the viewer, with their name and their height in metres, highest first.
GET qid, attribute.Name, aabb.height WHERE type = IFCDOOR
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. The height of the bounding box is aabb.height.
  2. ORDER BY … DESC sorts from large to small, and LIMIT cuts the sorted result.
  3. USING LENGTH_UNIT = m converts the height to metres.
Show solution
GET qid, attribute.Name, aabb.height WHERE type = IFCDOOR ORDER BY aabb.height DESC LIMIT 5 USING LENGTH_UNIT = m
Also accepted
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.

GoalDemo model · Schependomlaan
List the walls whose geometry is not watertight, with their name.
GET qid, attribute.Name WHERE type = IFCWALL
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. The flag is calculated.consistency.watertight.
  2. It is a boolean, so compare it with false.
Show solution
GET qid, attribute.Name WHERE type = IFCWALL AND calculated.consistency.watertight = false
Also accepted
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, the queries you run on a model you have never seen.