[Bf-python] Changing the scene in a script run from the command line

Tom Haines thaines at gmail.com
Thu Sep 9 23:14:10 CEST 2010


Hello all, and especially ideasman_42, who it was suggested to me
might be the person most likely to be able to help me on irc.
Unfortunately with me being in the UK and him in Australia the time
zones are kinda problematic, hence using the mailing list.

I am exporting a collada file from the command line with Blender 2.5,
specifically by running a .py file using the -P option, with -b to
avoid the gui appearing (Though it also fails if the -b option is
omitted.). This works, but the collada exporter exports entire scenes,
hence I want to set the scene before doing the export. My best effort
consists of:

bpy.context.screen.scene = bpy.data.scenes['scene_to_export']
bpy.ops.wm.collada_export(filepath='output_file.dae')

but the first line does not work (I have tried other ways, but they
all fundamentally involve setting the scene of the current screen.).
It fails silently, and neither changes the scene value of the screen
or bpy.context.scene, which is what I really want to change. Looking
at the api the only place I can see where the option to set the scene
is as part of a screen, and whilst that works when running the gui
(i.e. if entered into the console.) when run from the command line it
exports the contents of whatever scene was set when the .blend file
was saved, rather than the desired scene.

I can make a fair few guesses about what is going on, and it might
simply be the case that there is some undocumented api function I
need, but I'm basically stuck,
Thanks in advance for any help,
Tom



More information about the Bf-python mailing list