I am currently working on an importer for captured Shape Key motions. To fasten up the process, I am using the method suggested here. It works perfectly and saves up to a few minutes per import.

I am confused about the way the keyframes are displayed in the viewport. The keyframes show up in the Graph Editor and Dopesheet (Shape Key Editor view) like this:

enter image description here

Here is what I am doing:

if object_with_shape_keys:

    keyblocks = object_with_shape_keys.data.shape_keys.key_blocks

    for i, key in enumerate(keyblocks):

        if i == 0:
        # values captured in nano seconds:
        values = self.get_values_for_animation(shape_key_animation_values, frame_count, index = i-1)

        dp = 'key_blocks["{}"].value'.format(key.name)

        fc = self.get_fcurve(mocap_action, data_path = dp) or None

        # When there is no fcurve existing for that datapath,
        # then we can simply create a new one and populate it
        if not fc:

            fc = mocap_action.fcurves.new(dp, index = i)

            # Create new keyframe points and populate captured values
            fc.keyframe_points.add(count = frame_count)
            fc.keyframe_points.foreach_set('co', [x for co in zip(frames, values) for x in co])

The issue I am having with it is that the keyframes do not show up in the data tab in the object properties and I cannot get them to show up. It looks like this:

enter image description here

When I manually add a keyframe to one of the Shape Keys then I the interface looks like this:

enter image description here

What's worse is that after manually adding a keyframe, the previously working motion is overwritten for that specific Shape Key...

To summarize: There is a discrepancy between the keyframe_points stored in the individual fcurves and the keyframes displayed in the viewport. I am wondering if I am missing something or if this is intended behavior. I hope I made myself clear!

Thanks a lot in advance!

  • $\begingroup$ I can't reproduce, can you give more details? This is what I'm doing: pastebin.com/GG3rue3u $\endgroup$ – scurest Oct 5 '20 at 15:14
  • $\begingroup$ Hey scurest, thanks a lot for taking a shot at this.. I edited the question to include a snippet. The issue did not arise in your example, so it must be something I am doing in my script. The animation itself is working as it should. Worth noting that the data I am using is captured in nano seconds range which results in many subframes. I tried verifying this by modifying your example to subframes, but it still worked as expected... Let me know if you need more information. $\endgroup$ – f.bra Oct 5 '20 at 19:40


fc = mocap_action.fcurves.new(dp, index = i)

Delete index = i.

That sets fc.array_index which is for things like locations (index=0 targets X, 1 targets Y, etc.). You don't need it for shape keys.

  • $\begingroup$ Thank you! That was easier than expected! :) $\endgroup$ – f.bra Oct 6 '20 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.