Layers and organisation

Rhino's :: layer paths become nested Blender collections with the same names. Each object also carries a rhino_layer custom property with its full path.

Match on the rhino_layer property rather than the collection's .name when scripting. Blender de-duplicates collection names, so two layers with the same leaf name produce Walls and Walls.001.

Every layer gets a collection, and empty ones stay. Blender mirrors Rhino's whole layer tree, not just the parts of it currently holding geometry — layers with nothing on them, and layers switched off in Rhino, get collections too. Nothing is ever removed for merely being empty, so a collection survives deleting the last object on its layer, or moving that object to another layer.

This is what render-context tools need: they drive visibility per collection, so the collection has to exist for every layer you sync. It also keeps per-collection material assignments alive — the assignment lives on the collection, so a collection that vanished took it with it, and came back bare the next time the layer had geometry.

A collection is only removed once Rhino stops reporting its layer at all — the layer was deleted, or your layer filter no longer admits it — and never while it holds anything or carries a material assigned through a material-by-collection addon. The layer filter still works normally: only emptiness and visibility stopped being reasons to drop a layer.