0
$\begingroup$

I would like to store some properties in the scene, and on other bpy.data objects, I would like to create lists and dictionaries, but I am noticing that when the project is restarted, even if saved, these properties disappear. Example:

class SceneProp(bpy.types.PropertyGroup):
    
    test_dict_prop = {}
    test_list_prop = []
    classic_bpy_props: bpy.props.StringProperty() #etc
    
def register():
    bpy.types.Scene.scene_prop = bpy.props.PointerProperty(type=SceneProp)

I assumed that the properties of type not bpy.props were stored, but this is not the case, when blender is restarted, the dictionaries or the list will be empty. I foolishly thought it might work like that, but it isn't.

In addition, as far as a list is concerned, it could be solved with an EnumProperty, but it is not much for the purpose, as it will only be able to store strings, while I would also need to store Blender data objects.

Is there a practical solution? Always keeping pointed to a Blender property?

$\endgroup$
2
  • 1
    $\begingroup$ Short answer I think is no for PropertyGroups. You can use a CollectionProperty to store a List. For a dictionary I don't think you can at least not with some boilerplate, but you can directly assign custom properties as List or Dictionary though : blender.stackexchange.com/a/87871/86891 and blender.stackexchange.com/questions/53393/… $\endgroup$ – Gorgious Mar 27 at 8:38
  • $\begingroup$ Wow, this is science fiction to me, really useful, it works great, I didn't know about this possibility. $\endgroup$ – Noob Cat Mar 27 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.