How to create a Collection/List inside a Collection/List

Hello Blenderartists,

I want to create a Collection inside each item of a different Collection, but I can’t figure out how to achieve that. Has somebody an idea?

This ist what I tried

. . .

# Create a list property for Objects to be Baked
class BakeObjectList(bpy.types.PropertyGroup):
    '''name = bpy.props.PointerProperty()'''
    index = bpy.props.IntProperty()

    # Layers to be baked
    layers = bpy.props.PointerProperty(type = BakeLayerList)

# Create a list property for Bake Layers
class BakeLayerList(bpy.types.PropertyGroup):
    '''name = bpy.props.PointerProperty()'''
    index = bpy.props.IntProperty()
    
    active = bpy.props.BoolProperty()

def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.bake_objects = CollectionProperty(type = BakeObjectList)

def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.bake_objects

if __name__ == "__main__":
    register()

This works for me:

import bpy

class SubColl(bpy.types.PropertyGroup):
    bool = bpy.props.BoolProperty()
    
class Coll(bpy.types.PropertyGroup):
    sub_coll = bpy.props.CollectionProperty(type=SubColl)




def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.coll = bpy.props.CollectionProperty(type=Coll)
    
def unregister():
    bpy.utils.unregister_module(__name__)
    del bpy.types.Scene.coll


if __name__ == '__main__':
    register()
    
# use like:
scene = bpy.context.scene
item = scene.coll.add()
item.name = "Parent"
subitem = item.sub_coll.add()
subitem.name = "Child"
subitem.bool = True

Thank you, my proplem was that I used the wrong order. I have to define sub collections first