Tutorial·Learn BQL by doing

Properties and quantities

Read property sets and quantity sets by name or with the * wildcard, discover which sets a model has, and quote names that need it.

Most of what makes a model useful is not in the IFC attributes but in its property sets (psets) and quantity sets. BQL reaches both with a three-part path: the kind, the set, the name.

BQL#
GET qid, attribute.Name, property.Pset_WallCommon.IsExternal
WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true

property.Pset_WallCommon.IsExternal is the IsExternal property of the Pset_WallCommon set. Booleans are written true and false; strings and numbers as in the previous lesson. The same path works in GET and in WHERE.

When you do not know the set#

Property names are far more stable than set names: IsExternal lives in Pset_WallCommon on walls, Pset_DoorCommon on doors and Pset_SlabCommon on slabs. A * in the set position matches any set, so one condition covers them all:

BQL#
GET qid, type, attribute.Name WHERE property.*.IsExternal = true

The same wildcard exists for quantities (quantity.*.NetVolume) and, in the name position, gives you every member of a set (property.Pset_WallCommon.*). property.* on its own returns all properties of an object, which is a lot of columns but the fastest way to see what an object carries. Details and the field suffixes (.value, .unit, .propertySetName) are in Properties.

Discovering what a model has#

property.meta lists the property names an object has instead of their values. Grouped and counted (the grouping lesson explains the syntax), it is a survey of the model in one query — the doors of the demo model turn out to carry 2756 different property-and-set combinations, most of them one door supplier's own sets:

BQL#
GET property.meta, COUNT(qid) WHERE type = IFCDOOR GROUP BY property.meta

quantity.meta does the same for quantities. Run these before you rely on a name in a model you have not seen before.

Quoting names#

A set or property name is written bare when it looks like an identifier (letters, digits, underscore). Anything else needs double quotes: the demo model's custom set eigenschappen has a property called Rc-waarde, which is property.eigenschappen."Rc-waarde", and its wapening kg/m3 is property.eigenschappen."wapening kg/m3". Quote the set name too when it contains spaces.

Quantities and units#

Quantities follow the same path with quantity. The demo model has a BaseQuantities set on its building elements with Length, Width, Height, NetSideArea, GrossVolume, NetVolume and a few more. A quantity has a unit, so a comparison can carry one: quantity.*.Height > 2.5 m is read as 2.5 metres whatever unit the model uses internally, and > 2500 mm means the same. Without a unit the number is not converted: it is compared with the value as stored, in the internal unit (millimetres for lengths) or in the model's own unit depending on how the condition runs (unit#literals), which is easy to get wrong, so write the unit. Quantities describes the quantity kinds; the units lesson at the end of this course shows how to control the units in the result.

Besides the quantities the authoring tool exported, BIM.works computes its own from the geometry: calculated.quantity.volume, calculated.quantity.floorArea on spaces, aabb.height. They exist for every object with geometry, exported quantities or not, and the calculated values lesson uses them.

Watch out for the difference between the wildcard and a set name: 443 walls of the demo model are higher than 2.5 m when you ask with quantity.*.Height, but only 439 when you ask quantity.BaseQuantities.Height — four walls keep their height in the authoring tool's own set. The wildcard is the safer question.

Your turn#

GoalDemo model · Schependomlaan
List the external walls with their name and the IsExternal value from Pset_WallCommon.
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 property path is property.Pset_WallCommon.IsExternal.
  2. Add the same path to GET to see the value in the result.
  3. Booleans are lowercase.
Show solution
GET qid, attribute.Name, property.Pset_WallCommon.IsExternal WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true
Also accepted
GET qid, attribute.Name, property.*.IsExternal WHERE type = IFCWALL AND property.*.IsExternal = true

The JSON above is worth reading closely: a property leaf carries propertySetName, so the result tells you which set the value came from even when you asked with a wildcard.

GoalDemo model · Schependomlaan
List the walls that are both external and load-bearing, without naming a single property set.
GET qid, attribute.Name WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. Replace the set name by *.
  2. The second property is called LoadBearing.
Show solution
GET qid, attribute.Name WHERE type = IFCWALL AND property.*.IsExternal = true AND property.*.LoadBearing = true
Also accepted
GET qid, attribute.Name WHERE type = IFCWALL AND property.*.LoadBearing = true AND property.*.IsExternal = true
GoalDemo model · Schependomlaan
List the walls higher than 2.5 metres with their height and net volume.
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 quantities are called Height and NetVolume; use the * wildcard for the set.
  2. Write the unit in the comparison: 2.5 m.
Show solution
GET qid, attribute.Name, quantity.*.Height, quantity.*.NetVolume WHERE type = IFCWALL AND quantity.*.Height > 2.5 m
Also accepted
GET qid, attribute.Name, quantity.*.Height, quantity.*.NetVolume WHERE type = IFCWALL AND quantity.*.Height > 2500 mm
GoalDemo model · Schependomlaan
List the doors that have no FireRating property at all.
GET qid, attribute.Name 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. A property path without a comparator means "has a value".
  2. NOT in front of it means the opposite.
  3. Use the set wildcard so the set name does not matter.
Show solution
GET qid, attribute.Name WHERE type = IFCDOOR AND NOT property.*.FireRating
Also accepted
GET qid, attribute.Name WHERE NOT property.*.FireRating AND type = IFCDOOR

You can now#

  • Read a property or quantity by set and name, in GET and in WHERE.
  • Use * when the set name is unknown or varies by type.
  • Survey a model with property.meta and quantity.meta.
  • Quote names with spaces or punctuation.
  • Compare quantities with unit literals.

Next: Relations, from an object to the objects around it.