1
$\begingroup$

I'm using Blender to export GLB animation files for Web use. These animations are cloth simulations that are then transformed into shape keys by exporting an .fbx and .mdd file then imported back into blender. So essentially each frame becomes a shape key. This makes the file very large. How do I reduce the number of shape keys without wasting too much time? Is there an addon or script that can help?

$\endgroup$
2
  • $\begingroup$ Hello and welcome to BSE! do you mean reduce the amount of keyframes? Depends how many you want to remove and how far down you want to go. Like if you remove every other keyframe, you could theoretically reduce the size by 50%. Is that what you want? $\endgroup$ Aug 30, 2023 at 0:59
  • 1
    $\begingroup$ Thank you for the warm welcome! Yes, I mean reducing the amount of keyframes to achieve a smaller file size. I tried manually deleting every other keyframe but this breaks the animation for some reason and makes it go weird. $\endgroup$
    – cracklyf
    Aug 30, 2023 at 10:32

1 Answer 1

0
$\begingroup$

You can try run this script which will remove every other keyframe for all selected objects:

import bpy

selected_objects = bpy.context.selected_objects

for obj in selected_objects:

    if not obj.animation_data:
        continue

    for fc in obj.animation_data.action.fcurves:
        k = fc.keyframe_points
        for i in reversed((range(1, len(k), 2))):
            fc.keyframe_points.remove(k[i])
$\endgroup$

You must log in to answer this question.

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