Querry the whole list of IFC classes to bSDD for IDS writing

Hello, I want to have a small filter allowing people to select the correct classes proposed in the IFC Schema. I want to use bSDD in order to not having to downloadI FC Schema, making the application more logical.

The problem I encounter is the limit of a 1000 items.
Here is my code :

import requests

# Define the API endpoint
url      = 'https://api.bsdd.buildingsmart.org/api/Dictionary/v1/Classes?Uri=https%3A%2F%2Fidentifier.buildingsmart.org%2Furi%2Fbuildingsmart%2Fifc%2F4.3'
response = requests.get(url)# Send the GET request

if response.status_code == 200:             # Successful request
    data       = response.json()            # The response is in JSON format
    classes    = data.get('classes',[])     
    IfcClasses = []
    
    for c in classes : 
        name = c.get('referenceCode')
        print(name)
        IfcClasses.append(name)

This then does not give the complete list to filter correctly.

I also tried to use the /api/Class/Search/v1
The problem is that this does not work with only the ReferenceCode :
If the user search “Slab”, it will give me back all of the classes that mention something about slabs, like :

{
      "dictionaryUri": "https://identifier.buildingsmart.org/uri/buildingsmart/ifc/4.3",
      "dictionaryName": "IFC",
      "name": "Edgebeam",
      "referenceCode": "IfcBeamEDGEBEAM",
      "uri": "https://identifier.buildingsmart.org/uri/buildingsmart/ifc/4.3/class/IfcBeamEDGEBEAM",
      "classType": "Class",
      "description": "A beam on the longitudinal edge of bridge slab, usually concrete, providing additional stiffening and protection from the elements.",
      "parentClassName": "Beam",
      "relatedIfcEntityNames": []
    },

Hi @Enrra!

That search API has some powerful features like filtering to only dictionaries you want to see (use: “DictionaryUris” attribute). For example:

https://api.bsdd.buildingsmart.org/api/Class/Search/v1?SearchText=slab&DictionaryUris=https%3A%2F%2Fidentifier.buildingsmart.org%2Furi%2Fbuildingsmart%2Fifc

The 1000 limit is for pagination of the results, which is a common practice not to overload the transfer if you encounter a dictionary with many thousands of results. Simply check the number of results returned (“classesTotalCount” for IFC: 2163) and request second and third page. For example:

https://api.bsdd.buildingsmart.org/api/Dictionary/v1/Classes?Uri=https%3A%2F%2Fidentifier.buildingsmart.org%2Furi%2Fbuildingsmart%2Fifc%2Flatest&Offset=1000&Limit=1000

1 Like

Thank you for your answer !

I understand better. Do you know if there is an example of how to use this ? I am not to familiar with this filtering for example

In your example of search for instance, you find yourself with results that don’t have the slab word in the part reference code (like IfcBeam doesn’t have slab in it). It is impractical to filter.

Ok

One thing I now understand : the offset is what you meant by asking for a new page if I am not mistaken.

yes, you control pagination with limit and offset. Limit says about ‘number of items to be returned’ and Offset is a ‘zero-based offset of the first item to be returned.’

1 Like

A secondary question in the same line of thinking :

Is there a way to get a list of the different propertysets of a class easily ?

because with the endpoint : ‘https://api.bsdd.buildingsmart.org/api/Class/v1’ you can ask for the class properties, that gives you every properties and for each of their respective propertysets :

but you would have to skim trough every property and find out what is its propertyset in order to retrieve the complete list, which seems very impractical.

No, property sets are not objects in bSDD; they are only attributes of class properties.

2 Likes