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
Contributor

Added support for some pbone custom properties saving to metarig.
Custom properties widely used as a way to tweak rigs with drivers - so an option to save them to metarig will definitely help.

PS Accidentally removed the branch for #104414 so recreating PR

Added support for some pbone custom properties saving to metarig. Custom properties widely used as a way to tweak rigs with drivers - so an option to save them to metarig will definitely help. PS Accidentally removed the branch for #104414 so recreating PR
Andrej added 1 commit 2023-06-15 11:00:38 +02:00
Andrej requested review from Alexander Gavrilov 2023-06-15 11:01:34 +02:00
Member

@angavrilov hi, could you review this PR? :)

@angavrilov hi, could you review this PR? :)
Alexander Gavrilov requested changes 2023-09-05 12:43:46 +02:00
@ -414,1 +415,4 @@
# Custom properties
custom_properties = [
custom_property for custom_property in pbone.keys()

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

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

resolved in 3677cc4549

resolved in 3677cc454907e82731ac2360be5846d988e48e8c
@ -415,0 +428,4 @@
code.append(f" rna_idprop_ui_create(")
code.append(f" pbone, ")
code.append(f" '{custom_property}', ")
code.append(f" default={props_data['default']}, ")

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.
Author
Contributor

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.
Author
Contributor

resolved in 076763507e

resolved in 076763507e82ff209f546aba4b2ab03061254d9d
@ -415,0 +438,4 @@
if 'soft_max' in props_data:
code.append(f" soft_max={props_data['soft_max']}, ")
if 'description' in props_data:
code.append(f" description='{props_data['description']}'")

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.
Author
Contributor

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
Andrej added 3 commits 2023-09-09 18:58:54 +02:00
Andrej requested review from Alexander Gavrilov 2023-09-09 19:01:24 +02:00
Alexander Gavrilov requested changes 2023-09-25 12:21:19 +02:00
@ -415,0 +443,4 @@
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']})")

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.
Author
Contributor

Resolved in ca78100418

Resolved in ca78100418069ed45b340504ffcb55a03327627e
@ -415,0 +444,4 @@
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[{custom_property!r}] = {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.
Author
Contributor

resolved in 076763507e

resolved in 076763507e82ff209f546aba4b2ab03061254d9d
Andrej added 1 commit 2023-09-25 19:38:47 +02:00
Fixed:
- trailing spaces
- repr for default value
- don't set current value if it's the same as default
Andrej added 1 commit 2023-09-25 19:56:02 +02:00
Andrej requested review from Alexander Gavrilov 2023-09-25 20:00:04 +02:00
Alexander Gavrilov approved these changes 2023-09-25 21:50:59 +02:00
Alexander Gavrilov merged commit c9c0744ff7 into main 2023-09-25 21:52:59 +02:00
Andrej deleted branch rigify_custom_props 2023-09-25 22:16:26 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#104695
No description provided.