I am trying to create a script that will allow me to generate a list and store it in the blend file. The list starts out blank and then strings get added to the list, resulting in:
I create a PropertyGroup Class for the enum, define a new scene property as a CollectionProperty type with access to that enum Class, before appending a new item into the enum:
import bpy class item_set(bpy.types.PropertyGroup): myItems =  enums = bpy.props.EnumProperty(name="My Items", items=myItems) bpy.utils.register_class(item_set) bpy.types.Scene.myItemSet = bpy.props.CollectionProperty(type=item_set) newItem = bpy.context.scene.myItemSet.add() newItem.myItems.append("test")
I need to be able to add items to the list, save the blend file, re-open the file, run the script again and retrieve the list from the scene.
However, the documentation states:
One thing to keep in mind is that after saving and reloading your blend-file, your new property will have disappeared...
...To make the values you assigned in a previous session available again, you need to redefine the property. So after reopening the blend-file you need to rerun:
bpy.types.Object.myProperty = bpy.props.StringProperty()
I can do the appending into and retrieval of the property values absolutely fine upon an initial run, but as the documentation states, the property is unavailable when trying to view it's contents on a reload of the file (after having run the script, saved and re-opened the file), but I am unsure how to redefine it without clearing all it's values.
If I redefined the scene property, it would presumably also need the enum Class to be available, which would currently set
myItems back to
Do I need to change the way I am initially setting the items in the class or am I on entirely the wrong track with all of this? All I need to do is store a list in the blend file, so if there is a better way please let me know.
(I would hope, eventually, to be able to store sub lists
[["a","b"],["c","d"],["e","f"]], I'm just trying to get normal lists to work first.)