Fix #131495: Pose Library error with enum values
Enums in Blender evaluate to a string, so trying to add them to a pose failed with an error because FCurves only accept numbers. The fix is to modify the data path and split the property name off. By evaluating that we arrive at the bone, from which we can call `get(property_name)` to get the int value. Pull Request: https://projects.blender.org/blender/blender/pulls/132124
This commit is contained in:
committed by
Christoph Lendenfeld
parent
15aa7f882e
commit
6b421326b6
@@ -203,6 +203,15 @@ class PoseActionCreator:
|
||||
"""Resolve an RNA path + array index to an actual value."""
|
||||
value_or_array = cls._path_resolve(datablock, data_path)
|
||||
|
||||
if isinstance(value_or_array, str):
|
||||
# Enums resolve to a string.
|
||||
bone_path, enum_property_name = data_path.rsplit("[", 1)
|
||||
unescaped_property_name = bpy.utils.unescape_identifier(enum_property_name)
|
||||
# unescaped_property_name still has the quotes and a bracket at the end hence the [1:-2].
|
||||
value = cls._path_resolve(datablock, bone_path).get(unescaped_property_name[1:-2])
|
||||
assert isinstance(value, (int, float))
|
||||
return cast(FCurveValue, value)
|
||||
|
||||
# Both indices -1 and 0 are used for non-array properties.
|
||||
# -1 cannot be used in arrays, whereas 0 can be used in both arrays and non-arrays.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user