[Bf-python] Exporting multiple scenes

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Jan 27 18:33:16 CET 2012


Hi,

I think Sergey might have actually fixed this issue in latest svn, you
could try using a build from here:
http://builder.blender.org/

This scripts works for me now, while it didn't in the 2.61 release:

import bpy

act_ob = bpy.context.active_object
act_scene = bpy.context.scene

for scene in bpy.data.scenes:
    bpy.context.screen.scene = scene
    for ob in scene.objects:
        scene.objects.active = ob
        if ob.type == 'MESH':
            bpy.ops.object.mode_set(mode='EDIT')
            bpy.ops.mesh.quads_convert_to_tris()
            bpy.ops.object.mode_set(mode='OBJECT')

bpy.context.screen.scene = act_scene
act_scene.objects.active = act_ob

On Fri, Jan 27, 2012 at 4:54 PM, John Villar
<johnvillarzavatti at gmail.com> wrote:
> Hello, everyone, i'm currently working on my own format's exporter, and have
> been stumbling upon the same block for some months now (i asked here about
> this some time ago but no response worked correctly).
>
> My current exporter can succesfully export Single-scened files, multi-scene
> files are a real problem, because i cannot enter edit mode of my
> "non-current" scenes.
>
> Namely, i iterate over each scene like this:
>
>>>     arr_tmp = []
>>>
>>>     for sce in bpy.data.scenes:
>>>
>>>         bpy.context.screen.scene = sce
>>>
>>>
>>>         if bpy.ops.screen.frame_jump.poll():
>>>
>>>             bpy.ops.screen.frame_jump()
>>>
>>>             arr_tmp.append(export_scene_json(sce, export_binary))
>>>
>>>         else:
>>>
>>>             raise Exception("Couldn't poll frame_jump")
>
>
> And it works flawlessly, but then, inside "export_scene_json" when i iterate
> over the objects an triangulate them, it cannot set the edit mode of the
> objects because it cannot poll "bpy.ops.object.mode_set".
>
> I suppose this is because it is the second scene and blender hasn't set the
> current scene yet when i try to mode_set the objects.
>
> Is there a way i can solve this? Does blender have a function like "wait for
> the new scene to be settled" or something?
>
> I'm pulling out my hair here so please, bear with me :(
>
> John Villar
> Cell: (058)(416)926.86.45
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>



More information about the Bf-python mailing list