Query all objects of a given layer

Hi Dev Help!

So, I was recently introduced to querying streams via the browser using:

https://hestia.speckle.works/api/streams/

and then for objects:

https://hestia.speckle.works/api/objects/

is there a similar method for getting the objects of a layer? I was expecting something like

https://hestia.speckle.works/api/layers/

Thanks in advance

Stam

1 Like

Hi Stam, sorry for the late reply… There’s some previous discussion on layers here. To clarify:

Layers are not first class citizens in speckle, as some of the clients (ie, Revit, Excel) don’t support them due to how the host application works. Streams created from GH/RH/Dynamo do have a layers prop, it looks like this:

  "layers": [
            {
                "name": "Default",
                "guid": "98a30301-c29e-47be-9cac-84fee3dc4c45",
                "orderIndex": 0,
                "startIndex": 0,
                "objectCount": 4,
                "topology": "0-4 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "Black"
                    }
                }
            },
            {
                "name": "First Stream On Hestia | BknPYrRqM::B",
                "guid": "307ab6ca-c1ef-4814-a629-35aa4e58c946",
                "orderIndex": 1,
                "startIndex": 4,
                "objectCount": 2,
                "topology": "0-2 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "#AEECFD"
                    }
                }
            },
            {
                "name": "First Stream On Hestia | BknPYrRqM::C",
                "guid": "d6b3ea77-60eb-4258-8ded-831310ca273f",
                "orderIndex": 2,
                "startIndex": 6,
                "objectCount": 10,
                "topology": "0-10 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "#AEECFD"
                    }
                }
            },
            {
                "name": "First Stream On Hestia | BknPYrRqM::E",
                "guid": "baf67920-415c-46af-b5e4-54d9f701b662",
                "orderIndex": 3,
                "startIndex": 16,
                "objectCount": 180,
                "topology": "0-180 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "#AEECFD"
                    }
                }
            },
            {
                "name": "contours",
                "guid": "8858298c-8ed2-4771-8a3d-9a102ca2eef7",
                "orderIndex": 4,
                "startIndex": 196,
                "objectCount": 30,
                "topology": "0-30 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "Red"
                    }
                }
            },
            {
                "name": "planes",
                "guid": "ae2d5e42-e89e-4d3e-9f3b-22fb95bbfdc6",
                "orderIndex": 5,
                "startIndex": 226,
                "objectCount": 30,
                "topology": "0-30 ",
                "properties": {
                    "color": {
                        "a": 1,
                        "hex": "#8BFF77"
                    }
                }
            }
        ],

(https://hestia.speckle.works/api/streams/BJ9rGIA5f?fields=layers)

The important part is the startIndex and objectCount properties, which both refer to the main object list. startIndex refers to the to the uh… start index, and object count to how many objs you have to go forward. Essentially, the objects on a layer are objects[ layer.startIndex ] to objects[layer.startIndex + layer.objectCount].

This translates in the following query: https://hestia.speckle.works/api/streams/BJ9rGIA5f/objects?offset=6&limit=10 for the third layer in the stream above. More info on api queries that speckle supports can be found here.

I see! Thanks!

i guess you mean Length -1 i.e:

the objects on a layer are objects[ layer.startIndex ] to objects[layer.startIndex + layer.objectCount - 1] .

1 Like

guilty as charged :smiley: