Check if a layer has a positive list length, without loading geometry?

I’m looking for a boolean output, stating whether or not a layer is being used. I can achieve that by loading everything in that layer, but that is very slow because I potentially have a lot to load.

Well technically I’m looking for a way to automatically cull specific layers/subs if unused. The Create/Modify Layers component in Human has a handy feature for doing this but it’s pretty ruthless, it will delete the layer and bump the objects to another, rather than skip over it.

If there is a less ruthless delete layer function, that could be an easier alternative. Generative layering is a messy business.

I thought this was possible with the new R8/GH query options, but I didn’t find anything quickly, and I haven’t really studied them well - I then asked ChatGPT for fun, it gave an option through Python that outputs True or False depending on whether or not there are objects within layers but without obtaining nor displaying the objects.

For this example, I put things in the default layer only:


layer-objects-true-false.gh (7 KB)

Note:
If you were to delete objects within a layer, you need to recompute the definition for the output to update - I think you can do this with a timer too, but I don’t know for a fact