diff options
author | Hans Goudey <h.goudey@me.com> | 2021-08-27 16:29:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-08-27 16:29:15 +0300 |
commit | 104ba1c5682016a55b8a8ed06be52e0c05e913e9 (patch) | |
tree | 2c04f9a2d776b005a4791b646ced1ccf0b2d9daf /rigify | |
parent | 53c7859c9135eeb5274008d4d6caa8364ea0c308 (diff) |
Update addons for D9697 "_RNA_UI" removal
This is a followup patch for D9697 which applies the changes to the
addon reporistory. Almost all of the changes are in rigify, but there
is one change in "curve_tools" and two trivial changes in IO addons.
Differential Revision: https://developer.blender.org/D9919
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/generate.py | 2 | ||||
-rw-r--r-- | rigify/utils/mechanism.py | 24 |
2 files changed, 12 insertions, 14 deletions
diff --git a/rigify/generate.py b/rigify/generate.py index aa9a9a84..caff2633 100644 --- a/rigify/generate.py +++ b/rigify/generate.py @@ -21,7 +21,6 @@ import bpy import re import time -from rna_prop_ui import rna_idprop_ui_prop_get from .utils.errors import MetarigError from .utils.bones import new_bone @@ -415,7 +414,6 @@ class Generator(base_generate.BaseGenerator): #------------------------------------------ # Put the rig_name in the armature custom properties - rna_idprop_ui_prop_get(obj.data, "rig_id", create=True) obj.data["rig_id"] = self.rig_id self.script = rig_ui_template.ScriptGenerator(self) diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py index 92e161f6..00aef154 100644 --- a/rigify/utils/mechanism.py +++ b/rigify/utils/mechanism.py @@ -23,7 +23,7 @@ import re from bpy.types import bpy_prop_collection, Material -from rna_prop_ui import rna_idprop_ui_create, rna_idprop_ui_prop_get +from rna_prop_ui import rna_idprop_ui_create from rna_prop_ui import rna_idprop_quote_path as quote_property from .misc import force_lazy @@ -137,7 +137,7 @@ def make_property( """ # Some keyword argument defaults differ - return rna_idprop_ui_create( + rna_idprop_ui_create( owner, name, default = default, min = min, max = max, soft_min = soft_min, soft_max = soft_max, description = description or name, @@ -440,8 +440,9 @@ def deactivate_custom_properties(obj, *, reset=True): for key, value in obj.items(): valtype = type(value) if valtype in {int, float}: - info = rna_idprop_ui_prop_get(obj, key, create=False) or {} - obj[key] = valtype(info.get("default", 0)) + ui_data = obj.id_properties_ui(key) + rna_data = ui_data.as_dict() + obj[key] = valtype(rna_data.get("default", 0)) def reactivate_custom_properties(obj): @@ -462,21 +463,19 @@ def reactivate_custom_properties(obj): def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver=False, overridable=True): """Copy custom properties with filtering by prefix. Optionally link using drivers.""" res = [] - exclude = {'_RNA_UI', 'rigify_parameters', 'rigify_type'} + exclude = {'rigify_parameters', 'rigify_type'} for key, value in src.items(): if key.startswith(prefix) and key not in exclude: new_key = dest_prefix + key[len(prefix):] - info = rna_idprop_ui_prop_get(src, key, create=False) + ui_data_src = src.id_properties_ui(key) + if src != dest or new_key != key: dest[new_key] = value - if info: - info2 = rna_idprop_ui_prop_get(dest, new_key, create=True) - for ki, vi in info.items(): - info2[ki] = vi + dest.id_properties_ui(new_key).update_from(ui_data_src) if link_driver: make_driver(src, quote_property(key), variables=[(dest.id_data, dest, new_key)]) @@ -484,7 +483,7 @@ def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver= if overridable: dest.property_overridable_library_set(quote_property(new_key), True) - res.append((key, new_key, value, info)) + res.append((key, new_key, value)) return res @@ -500,7 +499,7 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o if mapping: panel = rig.script.panel_with_selected_check(rig, ui_controls or rig.bones.flatten('ctrl')) - for key,new_key,value,info in sorted(mapping, key=lambda item: item[1]): + for key,new_key,value in sorted(mapping, key=lambda item: item[1]): name = new_key # Replace delimiters with spaces @@ -513,6 +512,7 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o if name.lower() == name: name = name.title() + info = bone.id_properties_ui(new_key).as_dict() slider = type(value) is float and info and info.get("min", None) == 0 and info.get("max", None) == 1 panel.custom_prop(dest_bone, new_key, text=name, slider=slider) |