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.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?

  • 2
    $\begingroup$ Hello, you need to use a CollectionProperty instead of a PointerProperty. 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. $\endgroup$
    – Gorgious
    Feb 17, 2021 at 20:53
  • $\begingroup$ Thank you! I see my mistake now. It helps! ) $\endgroup$ Feb 17, 2021 at 21:43


You must log in to answer this question.

Browse other questions tagged .