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 076763507e - Show all commits

View File

@ -426,24 +426,25 @@ def write_metarig(obj: ArmatureObject, layers=False, func_name="create",
for custom_property, current_value in custom_properties.items():
props_data = pbone.id_properties_ui(custom_property).as_dict()
code.append(f" rna_idprop_ui_create(")
code.append(f" pbone, ")
code.append(f" {custom_property!r}, ")
code.append(f" default={props_data['default']}, ")
code.append(f" pbone,")
code.append(f" {custom_property!r},")
code.append(f" default={props_data['default']!r},")

What if the default isn't equal to the current value? This code doesn't preserve the value anywhere.

What if the default isn't equal to the current value? This code doesn't preserve the value anywhere.

resolved in 3677cc4549

resolved in 3677cc454907e82731ac2360be5846d988e48e8c

I'd quote default with repr too. Also, get rid of trailing spaces.

I'd quote default with repr too. Also, get rid of trailing spaces.

resolved in 076763507e

resolved in 076763507e82ff209f546aba4b2ab03061254d9d
if 'min' in props_data:
code.append(f" min={props_data['min']}, ")
code.append(f" min={props_data['min']},")
if 'max' in props_data:
code.append(f" max={props_data['max']}, ")
code.append(f" max={props_data['max']},")
if 'soft_min' in props_data:
code.append(f" soft_min={props_data['soft_min']}, ")
code.append(f" soft_min={props_data['soft_min']},")
if 'soft_max' in props_data:
code.append(f" soft_max={props_data['soft_max']}, ")
code.append(f" soft_max={props_data['soft_max']},")
if 'subtype' in props_data:
code.append(f" subtype={props_data['subtype']!r}, ")
code.append(f" subtype={props_data['subtype']!r},")

Rather than doing '{foo}', use {repr(foo)}. Manual quoting could be barely tolerated for property names, but for the description it is simply unacceptable.

Rather than doing `'{foo}'`, use `{repr(foo)}`. Manual quoting could be barely tolerated for property names, but for the description it is simply unacceptable.

that's really neat thing about repr, didn't know it can be used that way!
resolved in e2b63e1a4b

that's really neat thing about `repr`, didn't know it can be used that way! resolved in e2b63e1a4b07ffa8ca59eef5b4b2be17189f49ff
if 'description' in props_data:
code.append(f" description={props_data['description']!r}")
code.append(f" )")
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!r}).update(precision={props_data['precision']})")

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
if props_data['default'] != current_value:

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
code.append(f" pbone[{custom_property!r}] = {current_value}")
# Constraints