5
$\begingroup$

I've run a cloth bake. It runs from frame 0 to 60. I can see the results in the timeline from frame 0 to 60. I want to save various frames as a seperate shapekey for the cloth. For example I want to caputure the result at frame 20 as a seperate shapekey, and capture the result at frame 40 as a seperate shapekey. Is there a way to do this blender?

$\endgroup$

1 Answer 1

5
$\begingroup$

Make sure the "NewTek MDD format" add-on is enabled in the user preferences, and then select the object and go File > Export > Lightwave Pointcache (.mdd).

This will save a mesh cache file of the cloth simulation. Then you can remove the cloth simulation entirely (or just disable it if you might want to make changes later), and then import the .mdd file you just exported (File > Import > Lightwave Pointcache (.mdd)).

This will apply each frame of the simulation as a separate shape key on your object, and animate them on and off automatically for the appropriate frames.

shape keys

You can then delete all the shape keys that you don't want and remove the animation by right clicking on them and choosing Clear Keyframes.

If you have a few too many shape keys to remove by hand, a little bit of python can save a lot of time:

import bpy

obj = bpy.context.object

keys_to_keep = ["frame_0020", "frame_0040"]

i = 0
for s in obj.data.shape_keys.key_blocks:
    obj.active_shape_key_index = i
    if s.name not in keys_to_keep:
        bpy.ops.object.shape_key_remove(all=False)
    else:
        i += 1
$\endgroup$
3
  • $\begingroup$ Ok, thanks. I'll try out what your saying later on. I'll update this post on the results. It looks like a solution that will work $\endgroup$
    – TTTTTTa
    Commented Apr 22, 2016 at 20:40
  • $\begingroup$ Ok, I tried it out. It seems to work great. However, I found if the animation is not 100% complete from the start to end, when exporting it causes blender to hang. For example if the time line is set to go from 0 to 100 frames, and you only have run the animation to 50 frames, then when you do the export, Blender hangs up. Other than that, the plug in is working good. $\endgroup$
    – TTTTTTa
    Commented Apr 22, 2016 at 21:13
  • $\begingroup$ You can choose the frame range at the bottom left when exporting - it defaults to match the scene frame range, but you can tell it to stop at frame 40 if you want to. If the simulation for a certain frame isn't cached or baked when you export it, it'll get calculated during the export (which is why Blender hangs). $\endgroup$
    – Greg Zaal
    Commented Apr 23, 2016 at 9:12

You must log in to answer this question.

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