Tutorial·Learn BQL by doing

Surveying a model

Find out what a model you have never seen contains — its classes, its property and quantity sets, its materials and classifications, and the objects whose geometry will give trouble.

Every query so far assumed you knew what to ask for: that walls carry Pset_WallCommon, that the quantity set is called BaseQuantities, that the storeys have those Dutch names. On a model somebody has just sent you, none of that is given. This lesson is the survey you run first — five queries that tell you what is in the file before you write anything that depends on it.

What is in it#

The one query to remember, from the grouping lesson, with a sample object per class:

BQL#
GET type, COUNT(qid), FIRST(qid) GROUP BY type

39 classes in the demo model, IfcBeam 174 objects, IfcWall 652, IfcWallStandardCase 282, and so on. FIRST(qid) gives one deterministic member of each group, which is what you paste into the viewer to see what such an object actually looks like.

Which properties and quantities exist#

property.meta and quantity.meta return the names an object carries instead of their values, so grouping on them lists the vocabulary of the model:

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

Each row is one set-and-property combination with the number of objects that have it: 217 of them on the spaces of the demo model, from Pset_SpaceCommon to the authoring tool's AC_Pset_Zone_Stempel_18_KM. The doors are worse: 2756 property combinations and 1371 quantity combinations, most of them one door supplier's own sets. This is the query that tells you whether a check is even possible on a model, and under which name.

Materials, classifications and the header#

Three more questions worth asking, all from the earlier lessons:

BQL#
GET material.name, COUNT(qid) WHERE type = IFCWALL GROUP BY material.name
BQL#
GET classification.identity, COUNT(qid) WHERE type = IFCWALL GROUP BY classification.identity

The first shows which materials the walls are made of — twenty of them, from 01 Hout - hardhout (51 walls) to the cavity-wall leaves in 03 Metselwerk - kalkzandsteen C — the second which NL-SfB codes they carry (423 walls are 21.12). model.name, model.ifcVersion and the model.header.* features say what the file itself claims to be — IFC2X3_TC1 for Schependomlaan (Model).

What will give trouble#

The geometry the model came with is not always sound, and the objects that are unsound are the ones that will look wrong in a viewer, take too long to render or fail an export:

BQL#
GET qid, type, attribute.Name WHERE calculated.consistency.watertight = false

602 objects of the demo model, in fourteen classes. Worth knowing before you promise anybody a clean export.

Tip

The other half of surveying is spatial: which objects clash, what sits inside a space, how close two things are. Those constructs (CLASHES_WITH, geometry:contained_in, geometry:clearance) are on Spatial and advanced; they need clash detection and spatial querying enabled on the instance, and on this instance they answer nothing for the demo model, so this course leaves them to the reference.

Your turn#

GoalDemo model · Schependomlaan
Survey the model — one row per IFC class, with the number of objects and one sample object of that class.
GET type, COUNT(qid) GROUP BY type
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. FIRST(qid) returns one member of the group.
  2. It is a third GET item, next to the key and the count.
Show solution
GET type, COUNT(qid), FIRST(qid) GROUP BY type
Also accepted
GET type AS Class, COUNT(qid) AS Objects, FIRST(qid) AS Sample GROUP BY type
GoalDemo model · Schependomlaan
List the property vocabulary of the spaces: every set-and-property combination the spaces carry, with the number of spaces that have it.
GET property.meta 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. property.meta is a feature like any other, so it can be a group key.
  2. The count is COUNT(qid), as always.
Show solution
GET property.meta, COUNT(qid) WHERE type = IFCSPACE GROUP BY property.meta
Also accepted
GET property.meta AS Property, COUNT(qid) AS Spaces WHERE type = IFCSPACE GROUP BY property.meta
GoalDemo model · Schependomlaan
Show the walls that carry the NL-SfB classification "21.12" in the viewer, with their name and that classification.
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 relation is classification, and the field is identity.
  2. It works in WHERE as well as in GET, and the value is a string.
Show solution
GET qid, attribute.Name, classification.identity WHERE type = IFCWALL AND classification.identity = "21.12"
Also accepted
GET qid, classification.identity, attribute.Name WHERE type = IFCWALL AND classification.identity = "21.12"

Coloured in the viewer, a classification code stops being a string in a table: you see which walls of the building carry it, and whether the modeller was consistent about it.

You can now#

  • Ask an unknown model what classes, properties, quantities, materials and classifications it has.
  • Read a sample object per group with FIRST.
  • Find the objects whose geometry is not sound before they cause trouble.

Next: From query to IFC, where the result leaves BIM.works as a file.