Background scripts and context (blender 2.62)

Hi all,

I am not a big blender user, but I want to use it for 3D-visualization purposes.

I am trying to run the following script

import bpy


for i in steps:
    frame_num = i
    for s in scenes:
        my_obj =['MyObj']
        for x in
        scn =[0]

I need to run it in background mode, but it will always crash when using function like bpy.ops.object.shade_smooth() because of incorrect context.

Is there a way to apply such operators in background mode? Any workaround?

The point is that I absolutely need to re-open the blend file because each frame involves hundred of megabytes of data and this is (as far as I understand) the only way to free memory in blender.

Any suggestion?

Thanks a lot

If the intent is to simply set all the faces of the mesh to smooth then you can write your own auto smoother which will not require bpy.ops.

if my_obj.type == 'MESH':
    my_mesh =
    for face in my_mesh.faces:
        face.use_smooth = True

This may just move the error to the next usage of bpy.ops, however.


Hi Atom,

I did not see your answer.
Thanks a lot, the render operation does not seem to be a problem in background mode. It works perfectly!