Spatial and advanced

Geometry 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.

Everything on this page evaluates the geometry, the connectivity or the text index of the models rather than their attributes. Several functions need an instance capability (clash detection, text indexing, walkable surfaces, the BVH for headroom); a query that uses one on an instance without it fails with BimWorksQueryError.FEATURE_NOT_ENABLED.

Arguments#

Most functions take a target set: a boolean expression (type = IFCWALL), a list of qids, or a parameter bound to qids ($selected). The spatial predicates hold for an object when the relation holds between its geometry and the geometry of the target set.

Clash detection#

CLASHES_WITH(<target set>) is true for objects whose interior overlaps an object of the target set by at least the instance's intersect tolerance (5 mm by default, clash_detection.intersect_tolerance_mm): two objects that merely share a face, or a pipe in a hole cut for it, do not clash. An object fully inside a target counts. With a virtual shape as first argument, the shape is tested instead of the object's own geometry: CLASHES_WITH(BOX(this, 0, 0, 0, 1 m, 1 m, 1 m), <target set>) — the box sits on the object's own frame, its offsets and sizes are lengths, and the object itself is never its own partner. Clash detection is on by default (features.clash_detection); an instance that switches it off answers BimWorksQueryError.FEATURE_NOT_ENABLED.

Clash detection and clearance are bounded per request (see Limits).

BQL#
GET qid, attribute.Name WHERE type = IFCDUCTSEGMENT AND CLASHES_WITH(type = IFCBEAM)
BQL#
GET qid, type, attribute.Name WHERE CLASHES_WITH($selected)

Containment and contact#

Predicate True when the object's geometry …
geometry:contains_fully(<target set>) fully contains the geometry of a target object (the target may stick out by the contain tolerance, 25 mm by default).
geometry:contains_partially(<target set>) overlaps a target object by at least the intersect tolerance; a fully contained target counts.
geometry:contained_in(<target set>[, fully | partially | fully_or_partially]) lies inside a target object: fully — inside up to the contain tolerance; partially — overlapping but not fully inside; fully_or_partially (the default) — overlapping.
geometry:touches(<target set>) is within the touch margin of a target object (600 mm by default, clash_detection.touch_margin_mm), or overlaps it.

The tolerances are instance settings; the API task CalculateClashes2 takes them per call (predicate and margin_mm) and can return the run's counters (with_stats).

BQL#
GET qid, attribute.Name, space.attribute.LongName WHERE type = IFCFURNISHINGELEMENT AND geometry:contained_in(type = IFCSPACE, fully)
BQL#
GET qid, attribute.Name WHERE type = IFCWALL AND geometry:touches($selected)

Clearance#

geometry:clearance(<target set>[, DIRECTION(x, y, z[, local | world])]) is the minimum surface-to-surface distance from the object to the nearest target object: 0 when touching or penetrating, no value when the target set is empty. Compare it with <, <=, >, >= or BETWEEN, or select it with GET. The DIRECTION form (a directional clearance) is parsed but not implemented yet.

BQL#
GET qid, attribute.Name, geometry:clearance(type = IFCBEAM) UNIT mm AS Clearance WHERE type = IFCDUCTSEGMENT AND geometry:clearance(type = IFCBEAM) < 50 mm

Limits#

Clash detection, containment, contact and clearance share one budget per request, so a query cannot get past the limits by asking many small questions. A query that would go past a limit stops with BimWorksQueryError.QUERY_TOO_EXPENSIVE, and the message names the limit. Narrow one side with a WHERE condition. The defaults are instance settings in the clash_detection section:

Limit Default Setting
Candidate pairs (object pairs whose boxes overlap), summed over the request 1,000,000 query_max_candidates
Time spent in clash work, from the first clash call of the request 60 s query_max_seconds
Objects of the forms that run once per object: CLASHES_WITH(BOX(this, …)), GET CLASHES_WITH, geometry:clearance 20,000 query_max_objects
Largest side of a virtual BOX 50 m query_max_box_mm

A few requests run clash work at the same time (max_concurrent, 2). Another one waits up to queue_seconds (10 s) for a turn and otherwise stops with BimWorksQueryError.QUERY_BUSY. The API tasks (CalculateClashes2) and the clash model check have the same limits.

Virtual geometry#

BOX, CYLINDER, CONE and SPHERE describe a shape relative to the object (this) or its parent (parent): an offset in x, y, z followed by the size — BOX(source, ox, oy, oz, sizeX, sizeY, sizeZ), CYLINDER(source, ox, oy, oz, radius, height), CONE(source, ox, oy, oz, radius, height), SPHERE(source, ox, oy, oz, radius). Every argument is an arithmetic expression with units. A virtual shape is a GET feature (the viewers draw it). BOX is also the first argument of CLASHES_WITH; the other shapes are not supported there yet (NOT_IMPLEMENTED).

BQL#
GET qid, BOX(this, 0, 0, 0, 1 m, 1 m, 2.1 m) AS Envelope WHERE type = IFCDOOR
BQL#
GET qid, attribute.Name WHERE type = IFCDOOR AND CLASHES_WITH(BOX(this, 0, -1 m, 0, 1 m, 1 m, 2.1 m), type = IFCWALL)

Inscribed shapes#

Function Value
MAXIMUM_INSCRIBED_CIRCLE(geometry2d[, <subtract set>]) The largest circle in the object's footprint, optionally after subtracting the footprints of the subtract set; fields .diameter, .radius, .x, .y.
MAXIMUM_INSCRIBED_CYLINDER(geometry3d, <height>[, <subtract set>]) The largest cylinder of the given height inside the object's 3D geometry; fields .diameter, .radius, .x, .y, .z, .height.
MAXIMUM_INSCRIBED_SQUARE(geometry2d) The largest square in the footprint.
BQL#
GET qid, attribute.LongName, MAXIMUM_INSCRIBED_CIRCLE(geometry2d, type = IFCFURNISHINGELEMENT).diameter AS FreeDiameter
WHERE type = IFCSPACE AND MAXIMUM_INSCRIBED_CIRCLE(geometry2d, type = IFCFURNISHINGELEMENT).diameter < 1.5 m
BQL#
GET qid, MAXIMUM_INSCRIBED_CYLINDER(geometry3d, 2.1 m).diameter WHERE type = IFCSPACE

Usable area and headroom#

Function Value
geometry:usableArea(<height>) The floor area of a space with at least the given headroom (GET).
geometry:usableAreaFactor(<height>, <factor>) In WHERE: true when at least factor (0–1) of the area has the headroom; in GET: the factor itself.
geometry:headroom(<target set>, <height>) The clear height above the object's walking surface (faces up to 40° from horizontal) to the nearest object of the target set, in mm. GET gives it with the limiting object; in WHERE compare it with <, <=, >, >= or BETWEEN — nothing above counts as unlimited, an object without a walking surface matches no comparison. Needs the BVH on the instance.

The older spellings UseableAreaFeature, UseableAreaFactor, UseableAreaFactorFeature and Headroom still parse with a deprecation warning.

BQL#
GET qid, attribute.LongName, geometry:usableArea(2.1 m) UNIT m2 AS Usable WHERE type = IFCSPACE AND geometry:usableAreaFactor(2.1 m, 0.8)
BQL#
GET qid, geometry:headroom(type IN (IFCSLAB, IFCBEAM), 2300 mm) WHERE type = IFCRAMP AND geometry:headroom(type IN (IFCSLAB, IFCBEAM), 2300 mm) < 2300 mm

Space boundaries#

sem:isBoundedBy(<condition>) selects spaces bounded by an object matching the condition; sem:providesBoundariesFor(<target set>) selects the objects that bound the given spaces. Both rest on the model's IfcRelSpaceBoundary relationships.

BQL#
GET qid, attribute.LongName WHERE type = IFCSPACE AND sem:isBoundedBy(type = IFCWINDOW)
BQL#
GET qid, type, attribute.Name WHERE sem:providesBoundariesFor($spaces)

Paths and graphs#

The connectivity graph links spaces through doors, and distribution elements through their ports.

Predicate Selects
PART_OF(SHORTEST_PATH(<from>, <to>[, <through>])) The objects on the shortest path between the two sets, optionally restricted to pass through the third.
PART_OF(GRAPH(<from>, <maxSpan>)) The objects reachable from the set within maxSpan hops (maxSpan 1 returns the set itself).
DIRECT_CONNECTIONS_TO(<target set>[, <via set>]) A feature: the objects directly connected to a target, optionally via the given elements; selectable and testable.
BQL#
GET qid, type, attribute.Name WHERE PART_OF(SHORTEST_PATH(attribute.LongName = "Entrance", attribute.LongName = "Meeting room 1"))
BQL#
GET qid, type, attribute.Name WHERE PART_OF(GRAPH(type = IFCPUMP, 3))

On instances with walkable surfaces, the nav: family measures routes a person can walk, in metres over the floors, doors and stairs:

Construct Meaning
PART_OF(nav:route(<from>, <to>[, THROUGH(<spaces>)][, AGENT(...)])) The objects the cheapest walkable route traverses; per source the route goes to the nearest reachable target. <from> is one expression or one qid.
nav:reachable(<targets>[, THROUGH(<spaces>)][, AGENT(...)]) True for objects from which a target can be reached.
nav:routeLength(<targets>[, THROUGH(<spaces>)][, AGENT(...)]) The walking distance to the nearest reachable target; a GET feature and a comparable value; no value when unreachable.
nav:hasFallHazard(<drop>[, <guard>]) True for objects that support a walking surface with an unguarded drop deeper than <drop> (into an opening at least 300 mm wide), themselves or through their parts (a stair through its flights, a layered slab through its layers); a guard is a railing or parapet at least <guard> high (default 1 m).
nav:guardsFall(<surfaces>, <drop>[, <guard>]) True for the objects that guard a fall from the walking surfaces of <surfaces> (or of their parts): railings, parapets and walls standing at a drop edge deeper than <drop>, from 150 mm above the floor up to <guard> (default 1 m), where the guard is at least that high. These are what make nav:hasFallHazard pass with the same heights.

THROUGH(<spaces>) restricts the intermediate cells to the given spaces (door portals and stairs between allowed spaces stay allowed). AGENT(height: 1.85 m, radius: 250 mm, climb: 250 mm) sets the character, entries in any order, defaults 1800, 250 and 250 mm; a value without a unit is in millimetres.

Geo-reference#

geoReference WITHIN_EPSG(<code>) is true for objects of a model whose geo-reference is expressed in the given coordinate reference system; geoReference WITHIN_COUNTRY(NL) for a model located in the Netherlands (the only country code so far). gis:convertGeoReference(<epsg>) is a GET feature that returns the object's location converted to the given system.

BQL#
GET model.name, COUNT(qid) WHERE geoReference WITHIN_EPSG("28992") GROUP BY model.name
BQL#
GET qid, attribute.Name, gis:convertGeoReference("4326") AS WGS84 WHERE type = IFCBUILDING

Full-text search#

TEXT_MATCHES("<text>"[, FUZZY [n]]) searches every indexed text of the models (names, descriptions, property values) and is true for the objects that match; FUZZY allows up to n edits (1 or 2, default 1). The per-feature form is the MATCHES comparator (where#strings). Both need text indexing on the instance.

BQL#
GET qid, type, attribute.Name WHERE TEXT_MATCHES("fire door", FUZZY 1)

Viewpoints#

viewPoint (a GET feature) returns a camera position that looks at the object; viewPoint(<condition>) looks at the objects matching the condition from the object's position. It feeds the viewers and the report language.

BQL#
GET qid, attribute.Name, viewPoint WHERE type = IFCDOOR

Used in#