I recently started to learn Python and I started to develop a selection pie, which the user can quickly select objects and quickly switch between selection sets, like working with multiple character rigs and each rig has it's own selection set.
I'm trying to figure out what is the simplest way to switch between multiple lists, that can be stored in scene? I haven't figured out how to append objects to a ID property list, so I'm using a regular list, that the stored scene lists refer to and vice versa. But my functions refer to that temp list('curList'), which isn't stored in the scene.
So my problem is how I can have a function "know" what list it needs to stored and disconnect from the('curList'), before it switches to another list? I thought about saving all lists before making the switch, but I get an error that 'object can't be iterated' or something like that. But as an noob, I haven't figured out a way around that issue? :)
Here is a very simple example of what I'm trying to have functions do automatically.
import bpy
ctx = bpy.context
scn = ctx.scene
scn['list_a'] = ['']
scn['list_b'] = ['']
curList = []
curList = scn['list_a'] # tempList connects to sceneList
curList.append('Cube')
scn['list_a'] = curList # current sceneList gets updates from temp
scn['list_a'] = scn['list_a'] # current sceneList disconnects from temp
curList = scn['list_b'] # tempList switches to another sceneList
# etc.
Any suggestions or tips are hugely appreciated! :)
bpy.props.CollectionProperty
. See there for an example. Also since lists are not value types the variables only store a pointer to the construct in memory socurList = scn['list_a']
andscn['list_a'] = curList
are redundant $\endgroup$