BQL cheatsheet
Every clause, operator, function, unit and feature path of BQL on one page, each with a one-line example.
One line per construct; the page of each section has the details. Keywords are upper case, feature paths camelCase, IFC classes upper case, strings double-quoted.
Clauses#
| Clause | Example | Page |
|---|---|---|
| Bare selection | type = IFCWALL AND property.Pset_WallCommon.IsExternal = true |
WHERE |
GET |
GET qid, attribute.Name WHERE type = IFCDOOR |
GET |
AS |
GET attribute.Name AS Name, aabb.height AS "Height (mm)" |
get#alias |
UNIT |
GET quantity.Qto_WallBaseQuantities.NetSideArea UNIT m2 AS Area |
UNIT |
WHERE |
GET qid WHERE type = IFCSPACE AND attribute.LongName CONTAINS "office" |
WHERE |
GROUP BY |
GET type, COUNT(qid) GROUP BY type |
GROUP BY |
ORDER BY |
GET qid, aabb.height WHERE type = IFCDOOR ORDER BY aabb.height DESC, attribute.Name ASC |
ORDER BY, LIMIT and OFFSET |
ORDER BY ORIGINAL |
GET qid WHERE type = IFCWALL ORDER BY ORIGINAL |
order-by#original |
ORDER BY GEOMETRY |
GET qid WHERE type = IFCDOOR ORDER BY GEOMETRY(attribute.Name = "Entrance") |
order-by#geometry |
LIMIT, OFFSET |
GET qid WHERE type = IFCWALL LIMIT 50 OFFSET 100 |
order-by#limit |
USING |
GET quantity.* WHERE type = IFCWALL USING LENGTH_UNIT = mm AREA_UNIT = m2 VOLUME_UNIT = m3 |
USING and parameters |
| Comments | GET qid // a comment and /* a block */ |
reference/bql#conventions |
Logic#
| Operator | Example |
|---|---|
AND, OR, NOT, ( ) |
(type = IFCWALL OR type = IFCSLAB) AND NOT property.Pset_WallCommon.IsExternal = true |
ALL |
GET COUNT(qid) WHERE ALL |
| Has-value | property.*.FireRating |
| Null | property.Pset_DoorCommon.FireRating = null |
Comparators#
| Comparator | Example | Page |
|---|---|---|
= != < <= > >= |
aabb.height > 2.4 m |
where#comparisons |
| Feature to feature, arithmetic | quantity.*.NetVolume > calculated.quantity.volume * 1.1 |
where#comparisons |
WITHIN |
quantity.*.NetVolume = calculated.quantity.volume WITHIN 2 % |
where#within |
BETWEEN |
aabb.height BETWEEN 2.0 m AND 2.4 m, BETWEEN (2.0 m, 2.4 m) |
where#comparisons |
IN, NOT IN |
attribute.Name IN ("Wall-1", "Wall-2"), type NOT IN (IFCSPACE, IFCOPENINGELEMENT) |
where#comparisons |
CONTAINS, STARTS_WITH, ENDS_WITH |
attribute.Name STARTS_WITH "Basic" |
where#strings |
MATCHES_REGEX |
property.*.Nlsfb MATCHES_REGEX "^[0-9][0-9][.][0-9][0-9]$" |
where#strings |
MATCHES … FUZZY |
attribute.Name MATCHES "brandwerend" FUZZY 1 |
where#strings |
LENGTH |
attribute.Name LENGTH > 20 |
where#strings |
CS prefix |
attribute.Name CS = "Level 1", CS CONTAINS, CS NOT IN (...) |
where#strings |
type, NI |
type = IFCWALL, type NI = IFCWALL, type IN (IFCWALL, IFCDOOR) |
Types |
qid |
qid IN ("797e993c-a87f-4aa7-9587-c59d30ec5c4e-1316") |
where#qid |
| Parameters | = $x, IN $values, BETWEEN $lo AND $hi, type IN $types, qid IN $selection |
using#parameters |
Aggregates and functions#
| Function | Example | Page |
|---|---|---|
COUNT |
GET type, COUNT(qid) GROUP BY type |
group-by#aggregates |
SUM, AVG, MIN, MAX |
GET SUM(quantity.Qto_SpaceBaseQuantities.NetFloorArea) WHERE type = IFCSPACE |
group-by#aggregates |
MEDIAN, MODE, RANGE, STDDEV |
GET MEDIAN(aabb.height) WHERE type = IFCDOOR |
group-by#aggregates |
COLLECT |
GET type, COLLECT(qid) GROUP BY type |
group-by#aggregates |
COLLECT(DISTINCT …) |
GET type, COLLECT(DISTINCT attribute.ObjectType) GROUP BY type |
group-by#aggregates |
FIRST |
GET type, COUNT(qid), FIRST(qid) GROUP BY type |
group-by#aggregates |
BIN |
GET BIN(aabb.height, 500 mm), COUNT(qid) GROUP BY BIN(aabb.height, 500 mm) |
group-by#bin |
ABS, + - * / |
GET ABS(quantity.*.NetVolume - calculated.quantity.volume) UNIT m3 |
get#arithmetic |
CASE |
GET CASE WHEN type = IFCDOOR THEN "door" ELSE "other" END AS Kind |
functions#case |
COALESCE, GREATEST, LEAST |
GET GREATEST(calculated.quantity.width, attribute.OverallWidth) UNIT mm AS Width |
functions#missing |
ROUND, FLOOR, CEIL, MOD, POWER, SQRT |
GET ROUND(quantity.*.Length, 500 mm) UNIT m AS Band |
functions#numbers |
CONCAT, UPPER, LOWER, TRIM, LEFT, RIGHT, SUBSTRING, SPLIT_PART, REPLACE, REGEX_EXTRACT, CHAR_LENGTH |
WHERE SPLIT_PART(classification.identification, ".", 1) IN ("21", "22") |
functions#text |
TO_NUMBER, TO_STRING |
WHERE TO_NUMBER(property.*.Dikte, mm) > 100 mm |
functions#conversions |
COUNT(children) |
GET attribute.Name, COUNT(children) WHERE type = IFCBUILDINGSTOREY |
get#special |
eval |
GET qid, eval(property.Pset_WallCommon.IsExternal = true) AS External |
get#special |
| Relation aggregate | spaceBoundary(SUM(quantity.*.Area) WHERE type = IFCWINDOW) |
where#relation-aggregates |
Units#
| Dimension | Units |
|---|---|
| Length | mm cm dm m km in ft yd mi |
| Area | mm2 cm2 dm2 m2 km2 in2 ft2 yd2 ac mi2 |
| Volume | mm3 cm3 dm3 m3 in3 ft3 yd3 l |
| Mass | mg cg g kg |
| Temperature | dc |
UNIT, unit literals and USING take all of them (using#units).
Feature paths#
| Path | Example | Page |
|---|---|---|
qid, oid, type, niceType |
GET qid, type, niceType |
Types |
suggestedType, suggestion.<facet> |
GET suggestedType WHERE suggestion.status = "CONTRADICTION" |
types#suggestedtype |
attribute.<Name>, attribute.*, .value |
GET attribute.Name, attribute.GlobalId, attribute.* |
Attributes |
property.<Pset>.<Name>, property.*.<Name>, property.* |
GET property.Pset_WallCommon.IsExternal, property.*.FireRating |
Properties |
| Quoted names | property."AR_Ruum"."115_Kategooria" |
Properties |
| Fields | property.Pset_WallCommon.FireRating.value, .unit, .propertySetName |
properties#fields |
quantity.<Qset>.<Name>, quantity.* |
GET quantity.Qto_WallBaseQuantities.NetSideArea, quantity.*.Width |
Quantities |
classification.<field>, .system.<field> |
GET classification.identity, classification.system.name |
Classifications |
calculated.quantity.<name> |
GET calculated.quantity.floorArea, calculated.quantity.volume |
calculated-values#quantity |
calculated.property.<name> |
WHERE buildingStorey.calculated.property.level = 1 |
calculated-values#property |
calculated.geometry.<flag>, .counts.<n> |
WHERE calculated.geometry.counts.triangles > 100000 |
calculated-values#geometry |
calculated.consistency.<check> |
WHERE calculated.consistency.watertight = false |
calculated-values#consistency |
aabb.<side>, calculated.obb.<field> |
GET aabb.height, aabb.minz, calculated.obb.halfExtentX |
calculated-values#aabb |
layer.name, layer.* |
WHERE layer.name STARTS_WITH "A-" |
Layers |
material.<field>, material(...) |
GET material.name, material(name, layerThickness) |
Materials |
model.<field>, model.header.<field> |
GET model.name, model.ifcVersion, model.header.authors |
Model |
model.ifcVersion, model.discipline, model.count |
WHERE model.ifcVersion = IFC4 AND model.count(type = IFCSPACE) > 50 |
model#conditions |
linkedData, linkedData.count, linkedData.<field> |
GET linkedData.count WHERE linkedData.category = "Certificate" |
Linked data |
<family>.meta |
GET property.meta, COUNT(qid) GROUP BY property.meta |
Meta features |
Relations#
| Relation | Example | Page |
|---|---|---|
buildingStorey, space, building, site, project, containedIn |
GET buildingStorey.attribute.Name WHERE type = IFCDOOR |
Building storeys |
typeObject, own |
WHERE typeObject.attribute.Name CONTAINS "Double" |
Type objects |
parent, decomposes, children, allChildren |
GET children(qid, type WHERE type = IFCDOOR LIMIT 5) |
Sub-features and relations |
containmentChildren, decompositionChildren, decomposition |
GET decomposition WHERE type = IFCCURTAINWALL |
Sub-features and relations |
system, zone, port, portConnectedTo, portContainedIn |
GET port.portConnectedTo.portContainedIn.attribute.Name |
sub-features#systems |
spaceBoundary, relatedBuildingElement |
WHERE spaceBoundary.any(relatedBuildingElement.type = IFCWINDOW) |
sub-features#systems |
hasOpenings, hasFillings, fillings, fills, fillsVoid, voidsElement |
GET fillsVoid.voidsElement.attribute.Name WHERE type = IFCDOOR |
Openings and fillings |
.any, .all, .count |
WHERE children.count(type = IFCDOOR) > 2 |
sub-features#quantifiers |
Spatial and advanced#
| Construct | Example | Page |
|---|---|---|
CLASHES_WITH |
WHERE type = IFCDUCTSEGMENT AND CLASHES_WITH(type = IFCBEAM) |
spatial-and-advanced#clashes |
geometry:contains_fully, contains_partially, contained_in, touches |
WHERE geometry:contained_in(type = IFCSPACE, fully) |
spatial-and-advanced#geometry |
geometry:clearance |
WHERE geometry:clearance(type = IFCBEAM) < 50 mm |
spatial-and-advanced#clearance |
BOX, CYLINDER, CONE, SPHERE |
CLASHES_WITH(BOX(this, 0, 0, 0, 1 m, 1 m, 1 m), type = IFCWALL) |
spatial-and-advanced#virtual |
MAXIMUM_INSCRIBED_CIRCLE, _CYLINDER, _SQUARE |
GET MAXIMUM_INSCRIBED_CIRCLE(geometry2d).diameter |
spatial-and-advanced#inscribed |
geometry:usableArea, usableAreaFactor, headroom |
GET geometry:usableArea(2.1 m) |
spatial-and-advanced#usable-area |
sem:isBoundedBy, sem:providesBoundariesFor |
WHERE type = IFCSPACE AND sem:isBoundedBy(type = IFCWINDOW) |
spatial-and-advanced#space-boundaries |
PART_OF(SHORTEST_PATH(...)), PART_OF(GRAPH(...)), DIRECT_CONNECTIONS_TO |
WHERE PART_OF(GRAPH(type = IFCPUMP, 3)) |
spatial-and-advanced#paths |
nav:route, nav:reachable, nav:routeLength, nav:hasFallHazard, nav:guardsFall |
WHERE nav:routeLength(type = IFCSTAIR) > 30 m |
spatial-and-advanced#nav |
geoReference WITHIN_EPSG, WITHIN_COUNTRY, gis:convertGeoReference |
WHERE geoReference WITHIN_EPSG("28992") |
spatial-and-advanced#georeference |
TEXT_MATCHES |
WHERE TEXT_MATCHES("fire door", FUZZY 1) |
spatial-and-advanced#text |
viewPoint |
GET qid, viewPoint WHERE type = IFCDOOR |
spatial-and-advanced#viewpoint |
Ten queries#
BQL#
GET type, COUNT(qid) GROUP BY typeBQL#
GET qid, attribute.Name WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = trueBQL#
GET property.meta, COUNT(qid) WHERE type = IFCSPACE GROUP BY property.metaBQL#
GET buildingStorey.attribute.Name, COUNT(qid) WHERE type = IFCDOOR GROUP BY buildingStorey.attribute.NameBQL#
GET qid, quantity.Qto_DoorBaseQuantities.Width UNIT mm WHERE type = IFCDOOR AND quantity.Qto_DoorBaseQuantities.Width < 0.85 mBQL#
GET SUM(quantity.Qto_SpaceBaseQuantities.NetFloorArea) AS FloorArea WHERE type = IFCSPACE USING AREA_UNIT = m2BQL#
GET qid, attribute.Name WHERE type = IFCSPACE AND typeObject.attribute.Name CONTAINS "balkon"BQL#
GET qid, ABS(quantity.Qto_WallBaseQuantities.NetVolume - calculated.quantity.volume) UNIT m3 AS Deviation WHERE type = IFCWALL AND quantity.Qto_WallBaseQuantities.NetVolume != calculated.quantity.volume WITHIN 2 %BQL#
GET type AS Type, COUNT(qid) AS Count, FIRST(qid) AS Sample GROUP BY typeBQL#
GET qid, attribute.Name WHERE type = IFCSLAB AND calculated.quantity.volume > $minVolume