3
$\begingroup$

I have a python script where a cloth collides with a moving human body. During the animation of this scene, I need to obtain some data of the human's armature at specific frames, dependend on the frame step. Therefore I first render each frame with this line:

bpy.ops.render.render(animation = True)

where I obtain an image at each frame step which I do not really need. Next, I use this line to access the single frames:

bpy.context.scene.frame_set(frame)ter code here

With rendering:

everything work perfectly but takes a lot of time. Also I do not need the image data obtained.

without pre rendering (and therefore calculating) the Animation:

the cloth object does not fall properly (it freezes actually) and only the human's movements are calculated at each frame as it should be. The cloth stays in its initial position.

As I am fairly new to Blender and Computer Graphics my question is:

Is there another/faster way to calculate the animation? Does this calculation imply rendering always? So far I thought rendering is just for obtaining a realistic looking image with shading and so on.

$\endgroup$
2
$\begingroup$

You can set the current frame to the start of the simulation, then press alt+A to let Blender play through the simulation. That should also cache the animation, without having to render everything.

In Python, you can use bpy.ops.screen.animation_play() to start playback. Append a function to bpy.app.handlers.frame_change_post that checks the current frame number, and calls bpy.ops.screen.animation_play() again to stop playback and remove itself from frame_change_post.

$\endgroup$
  • $\begingroup$ Thats true, but how to do so using python? Since I just need to loop once over the animation and with the code: bpy.ops.scene.animation_play() it does not stop looping until the function is called again. Thanks anyway caching is the term I looked for $\endgroup$ – mrks Dec 19 '16 at 10:48
  • 1
    $\begingroup$ I've updated my answer to include an approach for a Python script to do this. $\endgroup$ – dr. Sybren Dec 19 '16 at 11:27

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.