From query to IFC
Turn a query into a partial IFC model, download it, and check it in another viewer — plus the other ways a result leaves BIM.works.
A query does not have to end in a table. The same statement that selects objects can cut them out of the model as a new IFC file, geometry and all: the selection is the filter, and the export writes a valid model containing exactly what the query returned, with the spatial structure (project, site, building, storeys) it needs to be a model rather than a heap of shapes.
The IFC output#
The Query operation returns IFC instead of JSON when the request asks for it with "format": "ifc"; "format": "ifcxml" gives ifcXML. The SDKs wrap the same call:
const url = await client.ifc.exportIfc([versionUuid], "GET qid WHERE type = IFCDOOR");
window.location = url;String url = client.getIfc().exportIfc(Set.of(versionUuid), "GET qid WHERE type = IFCDOOR");curl -X POST "$"https://bim.works"/openapi/ifc/Query" \
-H "Authorization: Bearer $BIMWORKS_TOKEN" \
-H "Content-Type: application/json" \
-o doors.ifc \
-d '{"models": [{"type": "VersionModelIdentifier", "uuid": "<version uuid of the first demo model>"}], "query": "GET qid WHERE type = IFCDOOR", "format": "ifc", "filename": "doors.ifc"}'What the query projects does not matter much for the file — the objects it selects do. GET qid WHERE type = IFCDOOR and GET qid, attribute.Name WHERE type = IFCDOOR produce the same model; the second one only tells you more on screen. The objects keep their own GlobalId, so the cut-out can be compared with the original, and the file names itself after the filename you pass.
An exported object carries its geometry, its properties and quantities, its materials and its place in the spatial structure. What it does not carry is the objects it relates to unless you selected those too: export a door and you get the door, not the wall around it. Select both when the receiver needs the context.
The other ways out#
| Form | Call | Good for |
|---|---|---|
| JSON records | Query, client.bim.query |
code that reads values |
| Qids only | Query format: qids, client.bim.queryQids |
selecting, colouring, hiding in a viewer |
| Count | Query format: count, client.bim.queryCount |
a number in a dashboard |
| CSV, XLS, XLSX | Query format: csv or xlsx, client.bim.tableExport |
a spreadsheet for someone else |
| IFC, ifcXML | this page | a model for another tool |
| BCF | the checks, not a query | issues with viewpoints |
Output describes each of them.
Your turn#
The round below exports what your query selects and gives you the file. Download it, open it in whatever IFC viewer you have — BIMcollab ZOOM, Solibri Anywhere, usBIM.viewer+, the IFC import of your authoring tool, or a fresh upload into BIM.works — and check that what you see is exactly what the goal asked for, with the geometry intact. The download link is a one-time stream: press Run again if you need the file a second time.
GET qid, attribute.Name WHERE type = IFCDOORHints
- The storey is a condition on buildingStorey.attribute.Name, as in the relations lesson.
- The GET list only decides what you see on screen; the WHERE decides what ends up in the file.
Show solution
GET qid, attribute.Name WHERE type = IFCDOOR AND buildingStorey.attribute.Name = "00 begane grond"GET qid WHERE type = IFCDOOR AND buildingStorey.attribute.Name = "00 begane grond"GET qid, attribute.Name WHERE type = IFCDOOR AND buildingStorey.calculated.property.level = 0Open the file you downloaded. You should see the doors of one storey, standing in the air where they stand in the building — no walls, no floors, because you did not select them. Count them: the number in the other viewer must be the number of rows in the round.
GET qid, type, attribute.Name WHERE type = IFCDOOR AND buildingStorey.attribute.Name = "00 begane grond"Hints
- Two classes in one condition: type IN (…) takes a list.
- The storey condition holds for both classes, so it stays where it is.
- A space is an IfcSpace, a door an IfcDoor.
Show solution
GET qid, type, attribute.Name WHERE type IN (IFCSPACE, IFCDOOR) AND buildingStorey.attribute.Name = "00 begane grond"GET qid, type, attribute.Name WHERE (type = IFCSPACE OR type = IFCDOOR) AND buildingStorey.attribute.Name = "00 begane grond"That file is a room book with doors in it: spaces carry their name, their number and their properties, and the doors show where one room leads to the next. It is a fraction of the megabytes of the full model, which is the point of exporting a query rather than the model.
You can now#
- Turn any selection into an IFC or ifcXML file, from the API or an SDK.
- Predict what a cut-out contains, and select the context the receiver needs.
- Choose between JSON, qids, a count, a spreadsheet and a model for a result.
Next: Final challenge, one query that uses everything.