Convert hierachic block structure into layer structure

I have a hierachic block structure and want to convert it into a hierachic layer structure. When i explode the blocks sometimes the color of the objects changes. So far i have not found out why

ConvertBlockToHierachicLayerStructure3_cmd.py (3.6 KB)
Layers.py (9.7 KB)

BlockToLayer.3dm (136.3 KB)

Hello - please try this plug-in, it may do what you want -

ExplodeBlocksToLayersV6.rhp (14 KB)

Unblock the rhp file in Windows explorer then drag and drop it onto Rhino. The command is
ExplodeBlocksToLayers

-Pascal