I want to create a collection property with certain sculpt brushes. Can this be done? I tried:

WindowManager.coll = CollectionProperty(type=bpy.types.Brush)

But I'm getting errors:

TypeError: CollectionProperty(...) expected an RNA type derived from ID
Exception in module register(): '/home/antoni4040/Documents/blender-2.79-linux-glibc219-i686/2.79/scripts/addons/Advanced_Brushes/__init__.py'
Traceback (most recent call last):
  File "/home/antoni4040/Documents/blender-2.79-linux-glibc219-i686/2.79/scripts/modules/addon_utils.py", line 350, in enable
  File "/home/antoni4040/Documents/blender-2.79-linux-glibc219-i686/2.79/scripts/addons/Advanced_Brushes/__init__.py", line 23, in register
  File "/home/antoni4040/Documents/blender-2.79-linux-glibc219-i686/2.79/scripts/addons/Advanced_Brushes/Brush_Menu/Brush_Menu.py", line 120, in registerBrushSelectionPanel
    WindowManager.coll = CollectionProperty(type=bpy.types.Brush)
ValueError: bpy_struct "WindowManager" registration error: coll could not register

Any ideas? Thanks


Make a PropertyGroup with a brush type member.

Can use a pointer property to point to an ID type, in this case a brush. brush = bpy.props.PointerProperty(type=bpy.types.Brush)

import bpy

# Assign a collection
class SceneSettingItem(bpy.types.PropertyGroup):
    name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
    brush = bpy.props.PointerProperty(type=bpy.types.Brush)


bpy.types.Scene.brushes = \

print("Adding All Brushes")

for brush in bpy.data.brushes:
    my_item = bpy.context.scene.brushes.add()
    my_item.name = brush.name
    my_item.brush = brush

Python console check after running script above.

>>> C.scene.brushes['Twist'].brush
  • $\begingroup$ Thanks. But to be totally honest, I was also wondering if I could add such a collection property to a template_ID_preview and get a preview with some custom brushes. Could you please tell me (if you know) if I'm on the right track or if I'm going the wrong way? $\endgroup$
    – Antoni4040
    Dec 30 '17 at 15:07

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.