I’m trying to wrap my head around why I’m getting different types of objects when I do this:
import bpy
from bpy.types import PropertyGroup
from bpy.props import *
from bpy.utils import register_class, unregister_class
class TOOL_Settings(PropertyGroup):
my_property: IntProperty(
name = "my_property",
description = "my_property",
min = 6,
max = 26,
default = 12,
)
classes = (
TOOL_Settings,
)
instance_classes = []
max_count = 4
bpy.types.Scene.instancetools = [x for x in range(max_count)]
for index in range(max_count):
id = f"TOOL_Settings_{index}"
propgroup = type(id,
(TOOL_Settings, PropertyGroup, ),
{"bl_idname" : id,
"count" : index
}
)
instance_classes.append(propgroup)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.Scene.singletools = PointerProperty(type=TOOL_Settings)
for index in range(max_count):
register_class(instance_classes[index])
bpy.types.Scene.instancetools[index] = PointerProperty(type=instance_classes[index])
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
del bpy.types.Scene.singletools
if __name__ == "__main__":
register()
print(type(bpy.context.scene.singletools), bpy.context.scene.singletools)
print(type(bpy.context.scene.instancetools[0]), bpy.context.scene.instancetools[0])
print(type(bpy.context.scene.instancetools[0][0]), bpy.context.scene.instancetools[0][0])
print(type(bpy.context.scene.instancetools[0][1]), bpy.context.scene.instancetools[0][1])
But what I get spat back in the console is this:
<class 'bpy.types.TOOL_Settings'> <bpy_struct, TOOL_Settings("")>
<class 'tuple'> (<built-in function PointerProperty>, {'type': <class '__main__.TOOL_Settings_0'>})
<class 'builtin_function_or_method'> <built-in function PointerProperty>
<class 'dict'> {'type': <class '__main__.TOOL_Settings_0'>}
Maybe I’m doing it totally wrong, but what I want to do is have distinct instances of a property group, so each instance can have unique values. Eventually I want to display these instance properties on unique sub-panels, but I’m falling at the first hurdle.
I get the expected bpy_struct object for the single instance of Tool_Settings, but I don’t get a bpy_struct object for the multi-instances.
Could anyone help?