3
$\begingroup$

I found a script on the web that is supposed to set key frames for driver driven shape keys. however its giving me an error. I need this so i can remove the drivers for the render farm I use wont allow scripts. Here is the script.

Import bpy

context = bpy.context
scene = context.scene
object = context.object

frame = scene.frame_start

while frame <= scene.frame_end:
scene.frame_set(frame)
for fcurve in object.data.shape_keys.animation_data.drivers.valu es(): 
object.data.shape_keys.keyframe_insert(fcurve.data _path)
frame = frame + 1

The error I get when ran is below

enter image description here

$\endgroup$

1 Answer 1

4
$\begingroup$

Just some syntactic errors (missing indents, etc.). Should work like this:

import bpy

context = bpy.context
scene = context.scene
object = context.object

frame = scene.frame_start

while frame <= scene.frame_end:
    scene.frame_set(frame)
    for fcurve in object.data.shape_keys.animation_data.drivers.values(): 
        object.data.shape_keys.keyframe_insert(fcurve.data_path)
    frame = frame + 1
$\endgroup$
5
  • $\begingroup$ This worked perfectly, however I now need to use this script to set key frames for shape keys on all frames of this animation. Do i just remove" _data. driver.drivers.values" from line 11? $\endgroup$ Apr 24, 2018 at 18:21
  • $\begingroup$ Tried altering the script to get it to set keyframes for the shapekeys for all frames but the result did not get me what i wanted. here is what i tried. 'code' import bpy context = bpy.context scene = context.scene object = context.object frame = scene.frame_start while frame <= scene.frame_end: scene.frame_set(frame) object.data.shape_keys.keyframe_insert frame = frame + 1 $\endgroup$ Apr 25, 2018 at 16:03
  • $\begingroup$ Sorry, but can you please specify your problem? The script sets all keyframes for the current object for all applied drivers, between the scene's start frame and its endframe. So it works for all frames. Or do you want it to make it for all objects? $\endgroup$
    – Ectras
    Apr 25, 2018 at 19:00
  • $\begingroup$ All is well, figured a work around. You have been awesome. Thanks my man. $\endgroup$ Apr 29, 2018 at 16:28
  • $\begingroup$ You also need to remove drivers for the keyframes to take effect - pastebin.com/EvQ05uYX $\endgroup$ Sep 17, 2022 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .