and I know that I can add a function to every item in that list by defining it inside MyListClass, but instead, I want to define a function that can be accessed from the base of the property (sorry if that’s incorrect, I’m not sure what the correct terminology is).
AKA, I want to be able to access my function from:
bpy.context.scene.my_list.my_function()
rather than:
bpy.context.my_list["my_item"].my_function()
Is this possible? The same question also applies to custom properties.
You can add a PointerProperty to the scenes which will contain both methods and list, e.g.:
class MyList(PropertyGroup):
pass
class Container(PropertyGroup):
list : CollectionProperty(type = MyList)
def my_function(self):
pass
bpy.utils.register_class(MyList)
bpy.utils.register_class(Container)
bpy.types.Scene.container = PointerProperty(type=Container)
Now you can do scene.container.my_function() and scene.container.list['item']. It is generally a good idea to have a large PointerProperty container in order not to pollute built-in blender properties of scenes, objects, etc.
Note the order of the registration: as Container uses MyList class the later should be registered first.