How to add/remove bpy.props Properties to/from existing PropertyGroup in Blender 2.91?
Let's say I've done the following:
import bpy
class MyProps(bpy.types.PropertyGroup):
test1 : bpy.props.IntProperty()
bpy.utils.register_class(MyProps)
bpy.types.Object.my_props = bpy.props.PointerProperty(type=MyProps)
How can I add "test2" IntProperty() to bpy.types.Object.my_props after that? And how can I remove it afterwards if I need to? I've tried to find something inside bpy.types.Object.my_props, bpy.types.Object.my_props[1]['type'], bpy.context.object.my_props - but there's nothing which would look like adding/removing methods.
Basically this is the same question as this:
Remove from CollectionProperty
but the described solution doesn't work for 2.91 anymore. I can't find .remove(), .clear(), .add() and any similar method which would allow to dynamically add/remove Properties to/from existing registered PropertyGroup.
Am I missing something?
CollectionPropertyinstead of aPointerProperty. The methods in the question you provided still work, but they need a Collection property. A PointerProperty only links to a single PropertyGroup, and a CollectionProperty to a dynamic collection of props. – Gorgious Feb 17 '21 at 20:53