1
$\begingroup$

There are a lot of simple examples to add custom properties, but since Blender 3.0 there have been some API changes that made it a bit confusing to create via python some custom properties to PoseBone with some adjustments to its internals. Can't find a solution...

Here is an example that somewhat worked in 2.9:

import bpy

    # Get the bone
    pbone = bpy.data.objects["Armature"].pose.bones["Bone"]
    
    # Create the custom property and assign a value
    pbone['myControl'] = 0
    
    # Check if _RNA_UI dictionary exists, if not create
    if "_RNA_UI" not in pbone.keys():
        pbone["_RNA_UI"] = {}
    
    # Update _RNA_UI dictionary with min, max, softmin, and softmax values for the custom property
    pbone["_RNA_UI"].update({"myControl": {"min":0.0, "max":1.0}})

I bet there are simpler ways to make it in 2.9, but this one worked for me. It HAS to be for PoseBone and not other types, because it should work for a rig. Of course I want also other options than min/max like "is Library overridable" but I'm breaking this into baby steps. Problem is that in 3.0 it's broken.

$\endgroup$
3
  • $\begingroup$ can you pls elaborate a bit more what you want to achieve? i we present you a solution which "just" adds a custom property to a pose bone - i think you won't be satisfied with that? and by the way: the custom property is for "bone" not just pose bone (AFAIK) because the answer would be : bpy.context.active_bone["cp"] = 4 $\endgroup$
    – Chris
    Jan 24 at 5:59
  • $\begingroup$ Hi, PrinterKiller, I think it would greatly help respondents if you presented a snippet of failing code? Then, perhaps, answers could come in the form of corrections. $\endgroup$
    – Robin Betts
    Jan 24 at 8:10
  • $\begingroup$ Sorry, updated the question to clarify the issue $\endgroup$ Jan 25 at 12:33

0

You must log in to answer this question.

Browse other questions tagged .