BQL
The BIM.works Query Language, clause by clause — what a query is, the order of its clauses, the model parameter, the response shape, and an index of every feature page.
BQL selects objects from one or more IFC models and returns features of them. This page is the map of the language; every clause and feature family has its own page below, and the BQL cheatsheet compresses all of them into one card. The grammar the parser is generated from is on the BQL grammar page.
What a query is#
A query has two halves. The selection is a boolean expression over objects (type = IFCWALL AND property.Pset_WallCommon.IsExternal = true); the projection is the GET list of features to return for each selected object (GET qid, attribute.Name). Either half can be omitted:
- A query without
GETis a bare boolean expression and returns the matching objects with their default fields. This is the form the viewers and the visualisation language use. - A query with
GETand noWHEREprojects every object of the models.
There is no FROM: the models are a parameter of the API call, not part of the query (models).
type = IFCWALL AND property.Pset_WallCommon.IsExternal = trueGET qid, attribute.Name, property.Pset_WallCommon.IsExternal WHERE type = IFCWALLClause order#
Clauses are optional but their order is fixed:
GET <feature> [UNIT <unit>] [AS <alias>], ...
WHERE <boolean expression>
GROUP BY <feature>, ...
ORDER BY <feature> [ASC|DESC], ... | ORDER BY ORIGINAL | ORDER BY GEOMETRY(<expression>)
LIMIT <n>
OFFSET <n>
USING LENGTH_UNIT = <unit> AREA_UNIT = <unit> VOLUME_UNIT = <unit> MASS_UNIT = <unit> TEMPERATURE_UNIT = <unit>| Clause | Page | Notes |
|---|---|---|
GET |
GET | Features, arithmetic, aggregates, AS aliases, nested relation queries. |
UNIT |
UNIT | Per GET item; converts one numeric feature. Not on aggregates. |
WHERE |
WHERE | Boolean expressions, comparators, string tests, tolerances. Requires GET before it; without GET write the expression on its own. |
GROUP BY |
GROUP BY | One or more keys; pairs with the aggregate functions. |
ORDER BY, LIMIT, OFFSET |
ORDER BY, LIMIT and OFFSET | Sorting, original order, spatial sequencing, paging. |
USING |
USING and parameters | Output units for the whole result; parameters ($name) are on the same page. |
A complete example#
The external walls of the demo model, largest side area first, with their storey and their net side area in square metres:
// External walls, largest first
GET
qid,
attribute.Name AS Name,
buildingStorey.attribute.Name AS Storey,
quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2 AS SideArea
WHERE
type = IFCWALL
AND property.Pset_WallCommon.IsExternal = true
AND quantity.Qto_WallBaseQuantities.NetSideArea > 5 m2
ORDER BY quantity.Qto_WallBaseQuantities.NetSideArea DESC
LIMIT 20Line by line: qid is the object's Qid; attribute.Name is the IFC attribute (Attributes); buildingStorey.attribute.Name follows the containment relation to the storey and reads its name (Building storeys); the quantity comes from the wall's base quantity set (Quantities) and is converted to m² (UNIT); the WHERE filters on type (Types) and on a property of the common property set (Properties); ORDER BY … DESC LIMIT 20 keeps the twenty largest (ORDER BY, LIMIT and OFFSET).
Models are a parameter#
A query never names a model. The API call that runs it carries the models: a list of version UUIDs in the SDKs (client.bim.query([versionUuid], query) in JavaScript, client.bim.query(query, Set.of(versionUuid)) in Java), or a models array of ModelIdentifier objects in the Query operation. One query runs over every model in the list at once, and each returned object carries the version it came from in its Qid. An empty model list is valid and only validates the query. The Model page describes the model.* features that read the model's own name, schema and header.
Response shape#
The result is a JSON array with one record per selected object (or per group when the query has GROUP BY). A record is an object whose keys are the selected feature paths; nested paths (buildingStorey.attribute.Name) become nested objects. An AS alias is the key of a computed column (arithmetic, UNIT, an aggregate); a plain feature keeps its path (get#alias). A leaf value is an object with the value and its metadata:
{
"qid": "797e993c-a87f-4aa7-9587-c59d30ec5c4e-1316",
"type": "IFCWALL",
"attribute": {
"Name": {"name": "Name", "type": "STRING", "value": "Basic Wall:Exterior", "classType": "IfcLabel"}
},
"property": {
"Pset_WallCommon": {
"IsExternal": {"name": "IsExternal", "type": "BOOLEAN", "value": true, "classType": "IFCBOOLEAN", "propertySetName": "Pset_WallCommon"}
}
}
}type is the BasicType of the value (STRING, BOOLEAN, DOUBLE, INT, ENUM, REFERENCE, …); numeric values carry a unit; properties and attributes that come from the object's type object carry origin: "type" (Type objects). Records omit features the object has no value for. Aggregates appear under their alias or else their keyword (COUNT, MAX, …); SUM and COLLECT under their full text, such as SUM(quantity.*.NetVolume) (output#values). The Output page has the full description, including the compact format and the IFC export.
Conventions#
- Keywords are upper case (
GET,WHERE,AND,IN,CONTAINS); feature names and relation names are camelCase (buildingStorey,typeObject); IFC class names are upper case (IFCWALL). - Strings are double-quoted:
"Level 1". Single quotes are accepted by the lexer, but every example and every writer of BQL uses double quotes. - Names with special characters (spaces, dashes, a leading digit) are quoted:
property."AR_Ruum"."115_Kategooria". Attribute names are never quoted; they follow the IFC schema and are case-sensitive. - Numbers are plain decimals with an optional unit:
2.5 m,500 mm,20 m2. There is no exponent notation. The minus sign is part of the number, so write subtractions with spaces:a - 3, nota -3. - Booleans and null are lower case:
true,false,null. - Comments:
// to the end of the lineand/* … */. - Case: string comparisons are case-insensitive unless prefixed with
CS; IFC class names must be upper case (ifcwallis rejected with a did-you-mean).
Pages#
Statement pages: GET · WHERE · GROUP BY · ORDER BY, LIMIT and OFFSET · UNIT · USING and parameters
Feature pages: Types · Attributes · Properties · Quantities · Classifications · Calculated values · Building storeys · Layers · Materials · Type objects · Sub-features and relations · Openings and fillings · Model · Linked data · Meta features
Further: Shapes: SLICE and PROJECTION · Spatial and advanced · Output · AST · BQL cheatsheet · BQL grammar
Errors a query can raise are listed under BimWorksQueryError on the error codes page.
Used in#
- Your first query — the first
GETandWHERE. - Run a BQL query — running a query from every SDK.
- Query multiple models — one query over several versions.
Pages#
- GETThe projection clause — which features a query returns, arithmetic over them, aliases, aggregates and nested queries over related objects.
- WHEREThe selection — boolean expressions over features, the numeric and string comparators, tolerances, has-value tests, relation paths with all/any/count, and relation aggregates.
- GROUP BYGrouping and the aggregate functions — COUNT, SUM, MIN, MAX, AVG, MEDIAN, MODE, RANGE, STDDEV, COLLECT and FIRST, single and multi-key groups, BIN buckets, and the grouped result shape.
- ORDER BY, LIMIT and OFFSETSorting on one or more features, ascending and descending, the original file order, spatial sequencing with GEOMETRY, and paging with LIMIT and OFFSET.
- UNITPer-feature unit conversion in GET — the UNIT clause, the length, area, volume, mass and temperature units, unit literals in expressions, and how converted values appear in the result.
- USING and parametersResult-wide unit conversion with USING LENGTH_UNIT, AREA_UNIT, VOLUME_UNIT, MASS_UNIT and TEMPERATURE_UNIT, the original_* fields, and query parameters ($name) with their binding rules.
- Functions and CASEValue functions in GET and WHERE — CASE, COALESCE, GREATEST and LEAST, rounding and maths, text functions, and the conversions between text and numbers — with their rules for units, missing values and mismatches.
- TypesThe IFC class of an object — type with inheritance, NI for exact matches, IN lists and parameters, niceType, occurrences versus type definitions, and the suggestedType and suggestion facets.
- AttributesDirect IFC attributes — attribute.Name and the other schema attributes, the wildcard, the name/type/value fields, references to other objects, and attribute.meta.
- PropertiesProperty sets and properties — property.Pset.Name, the set and name wildcards, quoted names, the fields of a property, list, enumerated, bounded and complex properties, origin, and property.meta.
- QuantitiesQuantity sets and quantities — quantity.Qset.Name, wildcards, the fields of a quantity, units, aggregating quantities, and quantity.meta.
- ClassificationsClassification references — identity, identification and itemReference, name and location, the classification system and its fields, wildcards, filtering, and classification.meta.
- Calculated valuesValues BIM.works derives from geometry and structure — calculated.quantity (floor area, volume, perimeter …), calculated.property (level, isExternal …), calculated.geometry flags and counts, consistency checks, aabb and obb.
- Building storeysThe storey an object belongs to — buildingStorey.attribute.Name and Elevation, the level index, filtering and grouping by storey, the storeys themselves, and the other spatial containers.
- LayersPresentation layers — layer.name, the wildcard, filtering on the layer, and layer.meta.
- MaterialsMaterials and material layers — material.name, color and layerThickness, the classification and properties of a material, the parenthesised multi-material form, filtering, and material.meta.
- Type objectsThe type definition of an occurrence — typeObject.attribute, typeObject.property, the merging of type and occurrence properties, origin, and the own relation.
- Sub-features and relationsReading features of related objects — the single-target and multi-target relations, dot and parenthesised forms, nested WHERE/ORDER BY/LIMIT, the all/any/count quantifiers in WHERE, systems, zones, ports, space boundaries and decomposition.
- Openings and fillingsThe void and fill relationships — hasOpenings and fillings from an element, hasFillings and voidsElement from an opening, fills and fillsVoid from a door or window.
- Shapes: SLICE and PROJECTIONMeasuring a set of objects as one shape — a horizontal SLICE at a height or a PROJECTION onto a plane, unioned before it is measured — its options, its members (area, outline as WKT or GeoJSON, the figure the viewer draws), where it can stand in a query, and how it behaves over several models.
- ModelFeatures of the model an object belongs to — model.name, id, versionUuid, ifcVersion, discipline, filesize and the header fields; the model conditions ifcVersion, discipline and count in WHERE.
- Linked dataThe linkedData feature — the files, links, texts and identifiers linked to an object on the version queried, their count, and per item its kind, family, extension, category, title, validity and state; in WHERE, objects with or without linked data and by what is linked.
- Meta featuresSurveying which features exist instead of reading their values — attribute.meta, property.meta, quantity.meta, classification.meta, layer.meta, material.meta and calculated.meta, and why they are GET-only.
- Spatial and advancedGeometry predicates and functions — CLASHES_WITH, geometry:contains/contained_in/touches/clearance, virtual BOX/CYLINDER/CONE/SPHERE, inscribed circles and cylinders, usable area and headroom, space-boundary semantics, SHORTEST_PATH and GRAPH traversal, walkable routes, geo-reference tests, full-text search and viewpoints.
- OutputWhat a query returns — the record and leaf value shapes, the value types, the plain and compact JSON formats, grouped results and groupPath slicing, qid-only and count results, table export, and the IFC and ifcXML output of the OpenAPI Query.
- ASTThe JSON form of a parsed query — how the tree is shaped, the __type discriminator, ParseQuery and AstToBql for converting in both directions, the MinimalBql form, and validation.
- BQL cheatsheetEvery clause, operator, function, unit and feature path of BQL on one page, each with a one-line example.
- BQL grammarThe Xtext grammar of BQL as shipped in this release.