---
title: Surveying a model
summary: Find 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.
order: 80
terms: [bql, pset, quantity-set]
see-also: [tutorials/bql/calculated-values, tutorials/bql/export-to-ifc, reference/bql/meta, reference/bql/model]
---

# Surveying a model

Every query so far assumed you knew what to ask for: that walls carry `Pset_WallCommon`, that the quantity set is called `BaseQuantities`, that the storeys have those Dutch names. On a model somebody has just sent you, none of that is given. This lesson is the survey you run first — five queries that tell you what is in the file before you write anything that depends on it.

## What is in it

The one query to remember, from the grouping lesson, with a sample object per class:

```bql {#classes}
GET type, COUNT(qid), FIRST(qid) GROUP BY type
```

39 classes in the demo model, `IfcBeam` 174 objects, `IfcWall` 652, `IfcWallStandardCase` 282, and so on. `FIRST(qid)` gives one deterministic member of each group, which is what you paste into the viewer to see what such an object actually looks like.

## Which properties and quantities exist

`property.meta` and `quantity.meta` return the *names* an object carries instead of their values, so grouping on them lists the vocabulary of the model:

```bql {#meta}
GET property.meta, COUNT(qid) WHERE type = IFCSPACE GROUP BY property.meta
```

Each row is one set-and-property combination with the number of objects that have it: 217 of them on the spaces of the demo model, from `Pset_SpaceCommon` to the authoring tool's `AC_Pset_Zone_Stempel_18_KM`. The doors are worse: 2756 property combinations and 1371 quantity combinations, most of them one door supplier's own sets. This is the query that tells you whether a check is even possible on a model, and under which name.

## Materials, classifications and the header

Three more questions worth asking, all from the earlier lessons:

```bql {#materials}
GET material.name, COUNT(qid) WHERE type = IFCWALL GROUP BY material.name
```

```bql {#classifications}
GET classification.identity, COUNT(qid) WHERE type = IFCWALL GROUP BY classification.identity
```

The first shows which materials the walls are made of — twenty of them, from `01 Hout - hardhout` (51 walls) to the cavity-wall leaves in `03 Metselwerk - kalkzandsteen C` — the second which NL-SfB codes they carry (423 walls are `21.12`). `model.name`, `model.ifcVersion` and the `model.header.*` features say what the file itself claims to be — `IFC2X3_TC1` for Schependomlaan ([[bql:model]]).

## What will give trouble

The geometry the model came with is not always sound, and the objects that are unsound are the ones that will look wrong in a viewer, take too long to render or fail an export:

```bql {#consistency}
GET qid, type, attribute.Name WHERE calculated.consistency.watertight = false
```

602 objects of the demo model, in fourteen classes. Worth knowing before you promise anybody a clean export.

```tip
The other half of surveying is spatial: which objects clash, what sits inside a space, how close two things are. Those constructs (`CLASHES_WITH`, `geometry:contained_in`, `geometry:clearance`) are on [[bql:spatial-and-advanced]]; they need clash detection and spatial querying enabled on the instance, and on this instance they answer nothing for the demo model, so this course leaves them to the reference.
```

## Your turn

```lesson {#lesson-1}
goal: Survey the model — one row per IFC class, with the number of objects and one sample object of that class.
show: json
check: rows
starter: |
  GET type, COUNT(qid) GROUP BY type
hints: |
  - FIRST(qid) returns one member of the group.
  - It is a third GET item, next to the key and the count.
solution: |
  GET type, COUNT(qid), FIRST(qid) GROUP BY type
accept: |
  - GET type AS Class, COUNT(qid) AS Objects, FIRST(qid) AS Sample GROUP BY type
```

```lesson {#lesson-2}
goal: List the property vocabulary of the spaces: every set-and-property combination the spaces carry, with the number of spaces that have it.
show: table
check: rows
starter: |
  GET property.meta WHERE type = IFCSPACE
hints: |
  - property.meta is a feature like any other, so it can be a group key.
  - The count is COUNT(qid), as always.
solution: |
  GET property.meta, COUNT(qid) WHERE type = IFCSPACE GROUP BY property.meta
accept: |
  - GET property.meta AS Property, COUNT(qid) AS Spaces WHERE type = IFCSPACE GROUP BY property.meta
```

```lesson {#lesson-3}
goal: Show the walls that carry the NL-SfB classification "21.12" in the viewer, with their name and that classification.
show: viewer
check: values
starter: |
  GET qid, attribute.Name WHERE type = IFCWALL
hints: |
  - The relation is classification, and the field is identity.
  - It works in WHERE as well as in GET, and the value is a string.
solution: |
  GET qid, attribute.Name, classification.identity WHERE type = IFCWALL AND classification.identity = "21.12"
accept: |
  - GET qid, classification.identity, attribute.Name WHERE type = IFCWALL AND classification.identity = "21.12"
```

Coloured in the viewer, a classification code stops being a string in a table: you see which walls of the building carry it, and whether the modeller was consistent about it.

## You can now

- Ask an unknown model what classes, properties, quantities, materials and classifications it has.
- Read a sample object per group with `FIRST`.
- Find the objects whose geometry is not sound before they cause trouble.

Next: [From query to IFC](export-to-ifc.md), where the result leaves BIM.works as a file.
