How can I have a property group for each shape key? (Dynamic property groups)

Full disclaimer: I am not great at BPY coding, I am pretty good at Python but Blender’s API is weird and hard to grok.

I have a script that adds some properties to the shapekey panel on an object in the Properties Editor, to simplify setting up drivers for the shapekey. It’s fairly simple (although not optimized at all):

My ArbCbsProperties is the PropertyGroup that adds properties to the shape key panel. Then, an operator uses

obj = context.object
arp_cbs_props = obj.arp_cbs_props

To get those properties and use them. Pretty basic stuff.

My problem is that this uses the same properties for all shape keys per object. arp_cbs_props is unique per object, so the properties are unique per object, but not per shapekey. I’d like to be able to have unique properties per shapekey- and, if possible, update them dynamically, creating a new property group when a shapekey is created.

I’ve tried- with my shaky and limited knowledge- to do this, with absolutely no success. Truthfully, I’m not even sure where to start here. Any help is greatly appreciated :slight_smile:

First: thanks for learning a new word for my vocabulary: grok :wink:

Hmm… :thinking: very quick look; but maybe from more afar above it (or simply totally wrong :sweat_smile: or groggy :stuck_out_tongue_winking_eye: )

When looking at docs.blender.org → api → bpy.props → propertygroup-example
…this is especially “associated” on materials like so:

bpy.types.Material.my_settings = bpy.props.PointerProperty(type=MaterialSettings)

and so on every material and/but you did yours on objects:

bpy.types.Object.arp_cbs_props = bpy.props.PointerProperty(type=ArpCbsProperties)

and not on the shapekeys which is bpy.types.ShapeKey ??

But of course for example docs.blender api info_quickstart custom-properties also says:

(Still) missing features:

  • Assign custom properties to every type.

…and then giving an example docs.blender api info_quickstart custom-properties → custom-properties without using the PropertyGroup at all…

2 Likes