Tutorial·Learn BQL by doing

Final challenge

Three rounds without new syntax: a report query, a grouped survey and a spatial selection, each one a statement you would write at work.

No new constructs on this page. Each round is a question someone actually asks about a model, and the answer needs several of the clauses you have learned at once. The hints are shorter than before on purpose; the BQL cheatsheet is the page to keep open next to this one.

The clause order never changes, and remembering it is half of writing a long statement:

Text#
GET <feature> [UNIT <unit>] [AS <alias>], ...
WHERE <condition>
GROUP BY <feature>, ...
ORDER BY <feature> [ASC|DESC], ...
LIMIT <n>
OFFSET <n>
USING <DIMENSION>_UNIT = <unit> ...

Your turn#

GoalDemo model · Schependomlaan
A wall report — the five external walls with the largest net side area, with their name, the storey they are on and that area in square metres, largest first.
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. Three columns besides qid: the name, the storey's name, the quantity NetSideArea.
  2. "External" is the property IsExternal; the set wildcard saves you looking the set up.
  3. ORDER BY … DESC on the same quantity, then LIMIT 5.
  4. USING AREA_UNIT = m2 converts the area of the whole statement.
Show solution
GET qid, attribute.Name, buildingStorey.attribute.Name, quantity.*.NetSideArea
WHERE type = IFCWALL AND property.*.IsExternal = true
ORDER BY quantity.*.NetSideArea DESC
LIMIT 5
USING AREA_UNIT = m2
Also accepted
GET qid, attribute.Name, buildingStorey.attribute.Name, quantity.*.NetSideArea AS Area WHERE type = IFCWALL AND property.*.IsExternal = true ORDER BY quantity.*.NetSideArea DESC LIMIT 5 USING AREA_UNIT = m2
GoalDemo model · Schependomlaan
A survey of the doors — how many doors each storey has, and the total area of their openings, per storey.
GET buildingStorey.attribute.Name, COUNT(qid) WHERE type = IFCDOOR GROUP BY buildingStorey.attribute.Name
Editing and checking need JavaScript; the solution is below, and every query runs in the app's Actions tree too.
Hints
  1. The count is already there; the second aggregate is a SUM over a quantity of the door.
  2. The quantity of a door opening is called Area in the demo model's BaseQuantities.
  3. An aggregate cannot carry UNIT; convert the statement with USING instead.
Show solution
GET buildingStorey.attribute.Name, COUNT(qid), SUM(quantity.*.Area)
WHERE type = IFCDOOR
GROUP BY buildingStorey.attribute.Name
USING AREA_UNIT = m2
Also accepted
GET buildingStorey.attribute.Name AS Storey, COUNT(qid) AS Doors, SUM(quantity.*.Area) AS OpeningArea WHERE type = IFCDOOR GROUP BY buildingStorey.attribute.Name USING AREA_UNIT = m2
GoalDemo model · Schependomlaan
The rooms of the ground floor ("00 begane grond") whose long name says they are a room ("kamer"), in the viewer, with their long name.
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. Three conditions: the class, the storey, and the word in the long name.
  2. The storey is a relation: buildingStorey.attribute.Name.
  3. CONTAINS matches a word anywhere in the value, and ignores case.
Show solution
GET qid, attribute.LongName
WHERE type = IFCSPACE AND buildingStorey.attribute.Name = "00 begane grond" AND attribute.LongName CONTAINS "kamer"
Also accepted
GET qid, attribute.LongName WHERE type = IFCSPACE AND attribute.LongName CONTAINS "kamer" AND buildingStorey.calculated.property.level = 0

Eleven rooms, coloured in the model. Try the same query with the first floor and you get nothing: up there the modeller named the spaces instal. ruimte, hal and berging, which is the sort of thing a survey (lesson 8) tells you before a check depends on it.

You have finished the course#

You can select objects, filter them on anything the model carries, follow the graph around them, summarise them, control the units, use what BIM.works computes, ask geometric questions and take the result out as a file.

From here:

  • The BQL cheatsheet — every construct on one page, one line each.
  • Run a BQL query — running queries from JavaScript, Java, .NET, PHP and the API.
  • BQL — the language clause by clause, when a construct needs its exact rules.
  • The Build a model viewer course — query results in a viewer of your own.
  • Spatial and advanced — the constructs this course only mentioned: clashes and containment, clearance, paths and graphs, walkable routes, usable area, virtual shapes, full-text search.

The other query languages are learned the same way: BCL checks a model against rules, BVL colours it, BUL changes it, and all of them use the BQL selections you have just learned.