[Bf-committers] bpy.context.scene.frame_set(i) issue

Bartek Skorupa bartekskorupa at bartekskorupa.com
Fri Jan 20 23:58:02 CET 2012


Hi,

I'd like to draw your attention to frame_set(i) method.
In many scripts we have to refresh the scene several times, sometimes  
we need to collect some data for every frame in the whole animation.
In such cases the only way I know in blender's python is to set the  
frame using bpy.context.scene.frame_set(frame)
Almost every exporter that base on baking the data and exporting them  
as "keyframe for every frame" use this kind of loop:

start = bpy.context.scene.frame_start
end = bpy.context.scene.frame_end
for frame in range (start, end + 1):
     bpy.context.scene.frame_set(frame)
     '''
     .... all the magic that needs data for each frame ....
     '''

My exporter to Adobe After Effects (io_export_after_effects.py) does  
exactly the same.

The issue here is that setting the frame sometimes takes ages.
I was once advised to use bpy.context.frame_current = frame
Well... It's very fast, but doesn't do the trick. It sets the frame,  
but doesn't update the scene and in most cases - this is what we want  
- We want to have our scene refreshed for every frame.

bpy.context.scene.frame_set(frame) method is so slow, that many  
exporters become almost useless or if not useless - very badly  
perceived because of their performance.
The process of simple export to After Effects can sometimes take  
several minutes and this is definitely not the performance we are  
looking for.
I looked through many existing exporters and they all use this method,  
so I suppose I'm not the only one facing "frame_set" speed issue.
Does anyone know other method to achieve refreshing the scene for  
every frame, but not that slow?

Isn't this performance a bug of some kind?

I'd appreciate any help.

Cheers,
Bartek Skorupa

www.bartekskorupa.com



More information about the Bf-committers mailing list