Learn BQL by doing
Ten lessons that take you from your first GET query to grouped, unit-converted, parameterised queries.
BQL is the query language of BIM.works: one statement selects objects from one or more models and says which of their features you want back. This course teaches it by doing. Every lesson ends in rounds where you write the query: the goal says what the result has to be, you edit until it is, and the page runs your query and the lesson's own solution against the same demo model and compares the two. Any query that produces the right result passes — there is no expected text, only an expected result.
What you will learn#
| Lesson | You can do this afterwards |
|---|---|
| Your first query | Select objects by IFC type and read their attributes. |
| Filtering with WHERE | Combine conditions, compare strings and numbers, match patterns. |
| Properties and quantities | Read property sets and quantity sets, with and without knowing the set name. |
| Relations | Follow an object to its storey, its type object and the elements around it. |
| Grouping and aggregates | Count, sum and collect per group; order and page the result. |
| Units and parameters | Convert units in the result, use unit literals, and bind values at run time. |
| Calculated values | Use the quantities, bounding boxes and consistency flags BIM.works derives from the geometry. |
| Surveying a model | Ask an unknown model what it contains before you query it. |
| From query to IFC | Cut a partial model out of a version and open it in another viewer. |
| Final challenge | Write a full statement, with relations, quantities, units and ordering, unaided. |
The lessons build on each other: a later lesson uses the constructs of the earlier ones without explaining them again. Follow them in order the first time.
The demo model#
Every account has a demo folder with IFC Schependomlaan.ifc, an IFC2x3 model of a small Dutch apartment building. The lessons refer to it as Schependomlaan and rely on a few facts about it:
- Six storeys, named
-1 fundering,00 begane grond,01 eerste verdieping,02 tweede verdieping,03 derde verdiepingand04 dak. - 934 walls (652
IfcWalland 282IfcWallStandardCase), 279 slabs, 259 windows, 205 doors and 100 spaces, among others. - Standard property sets such as
Pset_WallCommon,Pset_DoorCommonandPset_SpaceCommon, plus the authoring tool's own sets (ArchiCADProperties, a Dutch set calledeigenschappen). - A
BaseQuantitiesquantity set on most building elements (932 of the 934 walls), next to the authoring tool's ownArchiCADQuantitiesand, on the doors, a supplier's sets. - Lengths are millimetres in the file; BIM.works converts to whatever unit you ask for.
Object names are Dutch: walls are called binnenwand (inner wall) or buitenblad (outer leaf), doors stelkozijn or D1L, spaces woonkamer (living room) or keuken (kitchen). You do not need to understand them, only to type them.
How a round works#
A round is the block with Goal at its top. It has the goal, an editor with a starter query, and three buttons:
- Run (or Ctrl+Enter) executes your query on the demo model, then executes the lesson's solution, and compares the results. PASSED means your result is the one the goal describes; TRY AGAIN says what is different — too many objects, a missing column, the wrong order. A query that does not parse comes back with the server's own message and the line it stumbled on.
- Hint reveals one hint at a time.
- Reset puts the starter query back.
The comparison is on the result, never on your text, so every correct way of writing the query passes: another column order, an AS alias, type NI = where it makes no difference, a wildcard instead of a set name. Where a round has well-known alternatives, they are listed under Also accepted in the solution, and a test proves each of them passes. A few rounds are stricter on purpose, because the point of the round is a construct rather than the result: they insist on LIMIT, on UNIT, on USING, on a named column or on a parameter, or they refuse a hard-coded property-set name. The round says so when that is what went wrong.
The solution stays hidden until you have run a wrong query twice. Reading it earlier would cost you the lesson; running a query that does not work costs you nothing.
The rounds run against your own instance with the demo API token BIM.works stores in this browser when you sign in. Open BIM.works once in this browser and the rounds work; without it the goal, the hints and the solution are still there to read, and every query also runs in the Actions tree of the app (Run a BQL query).
Your progress is kept in this browser (per instance), not on the server: the dot next to each lesson in the rail shows what is passed, in progress or untouched, and the panel at the top of this page counts the rounds and can forget them again.
Conventions#
A few conventions hold everywhere in BQL, and the lessons assume them from the start:
- Keywords are uppercase (
GET,WHERE,GROUP BY); IFC class names too (IFCWALL, neverIfcWall). - Strings are double-quoted (
"woonkamer") and booleans lowercase (true,false); a feature written on its own means "has a value", andNOTin front of it means it has none. - Feature names are dot paths:
attribute.Name,property.Pset_WallCommon.IsExternal,quantity.BaseQuantities.NetVolume. - There is no
FROM: the models a query runs on are chosen by the caller, not in the query.
When you want the full picture of a construct, follow the reference links in each lesson; the BQL cheatsheet fits on one page and is a good companion while you learn.
Pages#
- Your first querySelect objects by IFC type with GET and WHERE, read their attributes, and limit the result.
- Filtering with WHERECombine conditions with AND, OR and NOT, compare numbers and strings, match lists, ranges and regular expressions.
- Properties and quantitiesRead property sets and quantity sets by name or with the * wildcard, discover which sets a model has, and quote names that need it.
- RelationsFollow an object to its building storey, its type object and the elements that bound a space, in GET and in WHERE.
- Grouping and aggregatesCount and sum per group with GROUP BY, name result columns with AS, and order and page the result with ORDER BY, LIMIT and OFFSET.
- Units and parametersConvert units per column with UNIT or per statement with USING, write unit literals in conditions, and bind values at run time with $parameters.
- Calculated valuesUse the quantities, bounding boxes and consistency flags BIM.works derives from the geometry itself, and compare them with what the authoring tool exported.
- Surveying a modelFind 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.
- From query to IFCTurn a query into a partial IFC model, download it, and check it in another viewer — plus the other ways a result leaves BIM.works.
- Final challengeThree rounds without new syntax: a report query, a grouped survey and a spatial selection, each one a statement you would write at work.