How to add custom properties from Python and edit their limits?

Hello,

It used to be possible to add custom properties and edit their limits, soft limits, etc., using the ‘_RNA_UI’ dict. See: python - Adding Other types of Custom Properties - Blender Stack Exchange and scripting - How to edit a custom property in a python script? - Blender Stack Exchange

But it seems this is no longer the case in Blender 3.0. Instead, a property is created, called ‘_RNA_UI’.
Annoyingly, this breaks compatibility with older versions.
Try as I might, I can’t find any documentation for this, not in the current API documentation nor in previous versions. Does anyone know the proper way to do this? Is it documented anywhere? Has the API changed, or have I found a bug?

1 Like

The operator that is called from UI changes is beefier than it was in 2.93 … but all I can get it out of it is cryptic errors such as:

File: build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Direct execution not supported

Here’s how I call it:

dp='bpy.data.objects["'+some_armature.name+'"].pose.bones["'+pb.name+'"]'
bpy.ops.wm.properties_edit(data_path=dp, property_name=name_of_prop,)

If you’re wondering if the Python API changed with a new version, the first thing to do is look at the release notes: Reference/Release Notes/3.0/Python API - Blender Developer Wiki That should have all the information you need.

1 Like

Thank you for your help, it was in there.
I honestly thought It wouldn’t be mentioned since (to my knowledge) it wasn’t documented in the past.
I appreciate that it’s been updated. I’ll update my scripts to work with the new API.

It doesn’t seem like the new way of doing things can set whether a property is library overridable, and I can’t get property_overridable_library_set from bpy_struct to work. (bpy_struct — Blender Python API)

pb.property_overridable_library_set("Prop", True)
#! TypeError: PoseBone.property_overridable_library_set("Prop") not found

pb.property_overridable_library_set(pb.path_from_id('Prop'), True)
#! AttributeError: PoseBone.path_from_id("Prop") not found

pb.property_overridable_library_set(pb.path_from_id()+'["Prop"]', True)
#! TypeError: PoseBone.property_overridable_library_set("pose.bones["Bone"]["Prop"]") not found

pb.property_overridable_library_set(pb["Prop"], True)
#! TypeError: property_overridable_library_set() argument 1 must be str, not int

pb.id_data.property_overridable_library_set(pb.path_from_id()+'["Prop"]', True)
#! TypeError: Object.property_overridable_library_set("pose.bones["Bone"]["Prop"]") not found

pb.id_data.property_overridable_library_set(pb.path_from_id()+'["Prop"]', True)
#! TypeError: Object.property_overridable_library_set("pose.bones["Bone"]["Prop"]") not found

pb.id_data.property_overridable_library_set("bpy.data.objects[\"Armature\"]."+pb.path_from_id()+'["Prop"]', True)
#! TypeError: Object.property_overridable_library_set("bpy.data.objects["Armature"].pose.bones["Bone"]["Prop"]") not found

The property name was “Prop”, with a capital P. But I couldn’t set it to Library overridable no matter what I tried.
Is there documentation available for this function? Any help? Thank you.

I think you missed one combination which should work :

pb.property_overridable_library_set('["Prop"]', True)

But I agree this is a bit weird, I would assume a UI custom property to be access without the brackets like you would a custom property defined in a script…

I also think this particular property should be copied over when using prop_to.update_from(prop_from). I don’t really understand why it is stored on a different data class than the other property attributes ?

Naw, I’m afraid that doesn’t work either. I’m at a loss…

Can anyone point me to some docs on rna_idprop_ui_create ?
https://docs.blender.org/api/current/search.html?q=rna_idprop_ui_create&check_keywords=yes&area=default
It isn’t in the Python API docs.

If someone has an answer of how to set is_overridable_library = true of a pose bone in an armature please hlp!
I need to set all library overriddable to true for vincent character because when I link it in blender 3.2 I dont have access to blenrig properties!