Copy item from one CollectionProperty to another

I have two panels. One panel is a generate panel to create a new object and the other panel is an edit panel to modify the object once it is created. I wanted the edit panel to initially have the same setting as the generate panel. However, I was having trouble succinctly coding this.

I have a class with all the properties:


class stgs(bpy.types.PropertyGroup):
    props = bpy.props
    hide_seed = props.BoolProperty(name='Seed', default=False,description='hide seed box')             
    hide_size = props.BoolProperty(name='Size', default=False,description='hide size box')
    hide_offset = props.BoolProperty(name='Offset', default=False,description='hide offset box')
    ....etc

I defined two collection properties of this class:


def register():
    sc = bpy.context.scene    
        
    bpy.utils.register_module(__name__)        
        
    bpy.types.Scene.generate_stgs = CollectionProperty(type=stgs)   
    bpy.types.Object.edit_stgs = CollectionProperty(type=stgs)    
    

However, when I try to set one equal to the other, I get an error:

bpy.context.selected_objects[0].edit_stgs[0] = bpy.context.scene.generate_stgs[0]
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
IndexError: bpy_prop_collection[index] = value: failed assignment (unknown reason)

Is there a way I can do this without writing a function to set each property equal to the other? I have hundreds of properties I need to do this for

Thanks a lot

Every items needs to be add()ed first, there’s no other way.

import bpy

scene = bpy.context.scene

scene.edit_stgs.clear()
for elem in scene.generate_stgs:
    item = scene.edit_stgs.add()
    for k, v in elem.items():
        item[k] = v

Ok thank you so much for the clarification, CoDEmanX!