Rigify - saving pbone custom properties to metarig #104695

Merged
Alexander Gavrilov merged 6 commits from Andrej730/blender-addons:rigify_custom_props into main 2023-09-25 21:52:59 +02:00
Showing only changes of commit 3677cc4549 - Show all commits

View File

@ -414,16 +414,16 @@ def write_metarig(obj: ArmatureObject, layers=False, func_name="create",
code.append(" pass") code.append(" pass")
# Custom properties # Custom properties
custom_properties = [ custom_properties = {
custom_property for custom_property in pbone.keys() property_name: value for property_name, value in pbone.items()

Iterate over items() to get both key and value.

Iterate over `items()` to get both key and value.

resolved in 3677cc4549

resolved in 3677cc454907e82731ac2360be5846d988e48e8c
if custom_property not in pbone.bl_rna.properties.keys() if property_name not in pbone.bl_rna.properties.keys()
and type(pbone[custom_property]) in (float, int) and type(pbone[property_name]) in (float, int)
] }
if custom_properties: if custom_properties:
code.append(' # custom properties') code.append(' # custom properties')
for custom_property in custom_properties: for custom_property, current_value in custom_properties.items():
props_data = pbone.id_properties_ui(custom_property).as_dict() props_data = pbone.id_properties_ui(custom_property).as_dict()
code.append(f" rna_idprop_ui_create(") code.append(f" rna_idprop_ui_create(")
code.append(f" pbone, ") code.append(f" pbone, ")
@ -442,6 +442,7 @@ def write_metarig(obj: ArmatureObject, layers=False, func_name="create",
code.append(f" )") code.append(f" )")
if 'precision' in props_data: if 'precision' in props_data:
code.append(f" pbone.id_properties_ui('{custom_property}').update(precision={props_data['precision']})") code.append(f" pbone.id_properties_ui('{custom_property}').update(precision={props_data['precision']})")
code.append(f" pbone[{custom_property!r}] = {current_value}")

This is still not using repr. Also, step and precision should now be supported directly by rna_idprop_ui_create, I fixed that recently.

This is still not using repr. Also, step and precision should now be supported directly by `rna_idprop_ui_create`, I fixed that recently.

Resolved in ca78100418

Resolved in ca78100418069ed45b340504ffcb55a03327627e
# Constraints # Constraints

If current_value is actually equal to default, this would be redundant.

If current_value is actually equal to default, this would be redundant.

resolved in 076763507e

resolved in 076763507e82ff209f546aba4b2ab03061254d9d
for con in pbone.constraints: for con in pbone.constraints: