Fix #133010: Rigify operators for copying rig-type parameters fail

The underlying issue was that the code was trying to directly assign a Python
dictionary to an add-on defined Group Property accessed via `[]` syntax, like
this:

```
to_bone['rigify_parameters'] = param_dict
```

That only works if 'rigify_parameters' does *not* already exist according to the
`[]` lookup, so this was failing whenever it already did.

This PR fixes that by simply deleting the property first when it already exists.

Co-authored-by: Ayoub ibn Muhammad <cl3m3c7@riseup.net>
Co-authored-by: Sybren A. Stüvel <sybren@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/135233
This commit is contained in:
Nathan Vegdahl
2025-03-07 12:53:56 +01:00
committed by Sybren A. Stüvel
parent 308e81fd8a
commit b634fd04ed
@@ -143,6 +143,12 @@ def copy_rigify_params(from_bone: bpy.types.PoseBone, to_bone: bpy.types.PoseBon
else:
rig_type = to_bone.rigify_type = from_type
# Delete any previously-existing parameters, before copying in the new ones.
# Direct assignment to this property, as happens in the code below, is only
# possible when there is no pre-existing value. See #135233 for more info.
if 'rigify_parameters' in to_bone:
del to_bone['rigify_parameters']
from_params = from_bone.get('rigify_parameters')
if from_params and rig_type:
param_dict = property_to_python(from_params)
@@ -161,11 +167,7 @@ def copy_rigify_params(from_bone: bpy.types.PoseBone, to_bone: bpy.types.PoseBon
copy_ref_list(getattr(to_params_typed, prop_name), ref_list, mirror=True)
else:
to_bone['rigify_parameters'] = param_dict
else:
try:
del to_bone['rigify_parameters']
except KeyError:
pass
return True