Your first query
Select objects by IFC type with GET and WHERE, read their attributes, and limit the result.
A BQL statement has two halves. GET lists the features you want in the result; WHERE says which objects to take them from. Run this against Schependomlaan:
GET qid, type, attribute.Name WHERE type = IFCDOORYou get one row per door. qid is the object's identifier in BIM.works (the Qid, a version UUID and an object id joined by a hyphen), type is its IFC class, and attribute.Name is the value of the IFC Name attribute. Every IFC attribute is reachable the same way: attribute.GlobalId, attribute.Description, attribute.LongName on spaces, attribute.Elevation on storeys. Attribute names are case-sensitive and spelled as in the IFC schema; the editor warns when it does not know one. The full list of what GET accepts is in GET, attributes in Attributes.
Types include their subtypes#
type = IFCWALL matches 934 objects in the demo model, although only 652 of them are literally IfcWall: the other 282 are IfcWallStandardCase, a subtype. Type matching follows the IFC inheritance tree, so type = IFCBUILDINGELEMENT matches every wall, slab, door, window and beam at once, and type = IFCPRODUCT matches everything with a place in the building. When you mean the exact class and nothing below it, add NI (no inheritance):
GET qid, attribute.Name WHERE type NI = IFCWALLTwo more spellings of the same idea are type IN (IFCDOOR, IFCWINDOW) and type != IFCSPACE; see Types. niceType is the class name written the way people write it (IfcWallStandardCase instead of IFCWALLSTANDARDCASE), handy for output.
What if there is no WHERE?#
Leave the WHERE out and you get every object of every model queried, which is rarely what you want but sometimes exactly right (GET qid, type is the quickest inventory of a model). The reverse also exists: a query that is only a condition, type = IFCSPACE, returns the matching objects with their qid. The viewer uses that form to resolve selections; in this course we always write GET, so the result shape is explicit. WHERE on its own, without GET, is a syntax error.
Keeping the result small#
LIMIT cuts the result to the first n rows, OFFSET skips rows before that. Without an ORDER BY (a later lesson) the order is the model's own order, which is stable for one version but carries no meaning.
GET qid, attribute.Name WHERE type = IFCWINDOW LIMIT 10Your turn#
Four rounds. Edit the starter query until the result is what the goal asks for, then press Run.
GET qidHints
- Spaces are IfcSpace objects; IFC class names are uppercase in BQL.
- The name is the IFC attribute Name: attribute.Name.
- A GET list is separated by commas, and the condition follows in WHERE.
Show solution
GET qid, attribute.Name WHERE type = IFCSPACEGET attribute.Name, qid WHERE type = IFCSPACEGET qid, attribute.Name AS Name WHERE type = IFCSPACEtype feature itself, not niceType.GET qid, attribute.Name WHERE type = IFCSPACEHints
- Only the type in the WHERE has to change.
- The class of an object is the feature named type; it can be selected like any other feature.
Show solution
GET qid, type, attribute.Name WHERE type = IFCDOORGET qid, attribute.Name, type WHERE type = IFCDOORGET qid, attribute.Name WHERE type = IFCWALLHints
- type = IFCWALL also matches the subtype IfcWallStandardCase.
- NI after type switches inheritance off.
- niceType is the readable class name.
Show solution
GET qid, niceType, attribute.Name WHERE type NI = IFCWALLGET qid, attribute.Name, niceType WHERE type NI = IFCWALLGET qid, attribute.Name WHERE type = IFCWINDOWHints
- GlobalId is an IFC attribute like Name.
- LIMIT goes at the end of the statement.
Show solution
GET qid, attribute.GlobalId, attribute.Name WHERE type = IFCWINDOW LIMIT 10GET qid, attribute.GlobalId, attribute.Name WHERE type = IFCWINDOW LIMIT 10 OFFSET 0You can now#
- Write a
GET … WHERE …statement and read the rows it returns. - Select objects by IFC class, with or without their subtypes.
- Read any IFC attribute of the selected objects.
- Cap a result with
LIMIT.
Next: Filtering with WHERE, where the condition becomes more than one type.