import bpy class GregId(bpy.types.PropertyGroup): name: bpy.props.StringProperty(default="") bpy.utils.register_class(GregId) bpy.types.Object.my_collection = bpy.props.CollectionProperty(type=GregId) TEST_VALUE = 5 cube = bpy.data.objects["Cube"] for i in range(TEST_VALUE): new = cube.my_collection.add() if i == (TEST_VALUE - 2): saved_obj = new print("before possible crash") saved_obj.name print("after possible crash")