1
$\begingroup$

I would like to register a collection property for a list to a property group that I have already created.

Unfortunately, this doesn't seem to work:

bpy.types.Scene.my_group = PointerProperty(type=MyGroupClass)
bpy.types.Scene.my_group.my_list = CollectionProperty(type=MyListClass)

This could help tidy up my code by simply accessing the list through the property group, rather than just from the scene like normal. Is this possible?

$\endgroup$
2
  • $\begingroup$ define the collection my_list as a member of the propertygroup. MyGroupClass $\endgroup$ – batFINGER Jan 16 at 18:26
  • $\begingroup$ Yep, that's it, thanks! $\endgroup$ – bob Jan 16 at 20:02
0
$\begingroup$

Thanks to @batFINGER for the answer.

I just had to use this code instead, using the actual class name instead:

bpy.types.Scene.my_group = PointerProperty(type=MyGroupClass)
MyGroupClass.my_list = CollectionProperty(type=MyListClass)
$\endgroup$
1
  • 1
    $\begingroup$ well kinda, this is monkey patching but it works Ok. Would rather see class Foo(PropertyGroup): my_list : bpy.props.CollectionProperty(type=Bar) and then Scene.foo = PointerProperty(type=Foo). But would need to monkey patch to have a collection that is also type Foo. $\endgroup$ – batFINGER Jan 16 at 20:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.