Fix #132195: Unable to key mesh attributes

The issue is that certain RNA paths cannot be generated to come
from an ID and `RNA_path_from_ID_to_property` will return no value.
We are using that function in the keyframing code to allow passing
in a pointer to a bone and a path relative to that bone.
Since there is currently no good way to find the path from the ID to an arbitrary
struct pointer (see #122427), this patch is a workaround that uses
the struct_pointer IF that happens to be an ID pointer.
Of course that still has the core limitation in place but until a
better solution is available on the RNA side this is the best we can do.

Pull Request: https://projects.blender.org/blender/blender/pulls/132552
This commit is contained in:
Christoph Lendenfeld
2025-01-02 16:39:21 +01:00
committed by Christoph Lendenfeld
parent 3c7041c11e
commit 2d1fc1bcdd
2 changed files with 18 additions and 3 deletions

View File

@@ -266,6 +266,15 @@ class InsertKeyTest(AbstractKeyframingTest, unittest.TestCase):
self.assertEqual('show_wire', fcurves[0].data_path)
self.assertEqual(["Téšt"], [group.name for group in fgroups])
def test_keyframe_insert_nested_rna_path(self):
bpy.ops.mesh.primitive_cube_add()
obj = bpy.context.object
obj.data.attributes.new("test", "FLOAT", "POINT")
self.assertTrue(obj.data.keyframe_insert('attributes["test"].data[0].value'))
fcurves = obj.data.animation_data.action.fcurves
self.assertEqual(len(fcurves), 1)
self.assertEqual(fcurves[0].data_path, 'attributes["test"].data[0].value')
class VisualKeyingTest(AbstractKeyframingTest, unittest.TestCase):
""" Check if visual keying produces the correct keyframe values. """