I’m storing some data in a Python array (because CollectinProperty is too slow when I have a lot of data) which is stored inside a PropertyGroup attached to scene, like so:
class ToolkitProps(PropertyGroup) :
AtomList = []
# Lots of other properties
def register() :
bpy.utils.register_module(__name__)
bpy.types.Scene.toolkit_props = PointerProperty(type = ToolkitProps)
The UI is a toolbar. When I click one of the toggle buttons on the toolbar (which is layout.prop for one of the properties inside the same PropertyGroup, ToolkitProps), that triggers an update function that populates AtomList by assigning some array to self.AtomList. But there’s a problem! Say I have this code at the end of that function:
print(self)
print(context.scene.toolkit_props)
print("done loading", len(context.scene.toolkit_props.AtomList), len(self.AtomList))
The output is:
<bpy_struct, ToolkitProps("")>
<bpy_struct, ToolkitProps("")>
done loading 0 11
I’m confused. I only have one scene. Does self refer to the same thing as context.scene.toolkit_props or not? If yes, then how come the different references give me different AtomLists? I know I can just always refer to the AtomList as context.scene.tookit_props.AtomList, but it’s hefty, and I’m more interested in why this doesn’t work.