Skip to content

JSON Queries

Ruben de Laat edited this page Nov 17, 2016 · 14 revisions

The new query language is still in development, so expect this to change.

You can read the original motivations to write this language here

Intro

Some characteristics to of this language to keep in mind:

  • The data model of the "queried" is the same data model as the "query results". In most cases it will be Ifc2x3tc1 or Ifc4
  • The previous also explains why there are no aggregates, because there is no place to store those
  • A query result is always a subset of the original model
  • Query language is probably not the best term here, a "filter language" might be better
  • The queries are based on objects. Geometry is not treated any other way. If you don't ask for geometry, you won't get it.

JSON

All queries must be valid JSON. This means that all keys must be quoted, all strings must be quoted. When you send your query to BIMserver via the ServiceInterface.download call via JSON, make sure to base64 encode your query.

Downloading models

Base query

This query will query all objects.

{
}

Type query

This query will get all IfcWall objects

{
  "type": "IfcWall"
}

When your model for example only contains IfcWallStandardCase objects, this query will not return any objects, although IfcWallStandardCase is a subtype of IfcWall. To include subtypes, you have to explicitly define this:

{
  "type": "IfcWall",
  "includeAllSubtypes": true
}

You can also query multiple types, the next example would give you all IfcDoor and IfcWindow objects

{
  "types": ["IfcDoor", "IfcWindow"]
}

# GUID query

When you already know the GUID(s) of (an) object(s), you can query those directly:
```json
{
  "guids": ["GUID1", "GUID2"]
}

OID query

The same as for GUIDs, you can also query by OID (ObjectID)

{
  "oids": [1523, 2130, 898]
}

Serializing to IFC

In a lot of cases, the results of the query will be serialized as IFC. The previous examples would however not result in valid IFC files. For an IFC file to be valid, it not only has to solely contain objects that conform to the IFC schema, also certain references should always be included. For example every object must have an IfcOwnerHistory. Also there must always be an 1 IfcProject object.

Example of the body of an IFC file for the IfcWall query:

#1= IFCWALLSTANDARDCASE('1hmUg1hfv4UPf0UtHFe7ta',$,'SW - 009',$,$,$,$,'6BC1EA81-AE9E-4479-9A-40-7B744FA07DE4');
#2= IFCWALLSTANDARDCASE('05UYVl82vAa8mFc3FMTYL7',$,'SW - 010',$,$,$,$,'057A27EF-202E-4A90-8C-0F-9833D6762547');
#3= IFCWALLSTANDARDCASE('37ZZt1nzL2nu6PjSr0Wa2a',$,'SW - 011',$,$,$,$,'C78E3DC1-C7D5-42C7-81-99-B5CD408240A4');
#4= IFCWALLSTANDARDCASE('1EzyXtTtv7RAinwkFVr6_I',$,'SW - 012',$,$,$,$,'4EF7C877-777E-476C-AB-31-EAE3DFD46F92');
#5= IFCWALLSTANDARDCASE('08u2EMNSnBL8Izk3LNHAwK',$,'SW - 013',$,$,$,$,'08E02396-5DCC-4B54-84-BD-B8355744AE94');
Clone this wiki locally