[Bf-python] Automating tasks in blender via blender --python script.py

Bassam Kurdali bassam at urchn.org
Wed May 2 16:22:54 CEST 2012


Quick question: what are you trying to do? Can you avoid using operators and just do it using bpy.data?
On Wed May   2 2012 07:59:45 AM EDT, Rodrigo Benenson <rodrigo.benenson at gmail.com> wrote:

> Dear Blender mailing list,
> 
> I just spent 3 hours on the blender IRC trying to figure out how to
> automate a specific task using a python script called via "blender
> --python script.py".
> 
> The purpose of the script is to open a blender file, apply some
> operations and save the new blender file.
> This must be done without any click from the user, so that the process
> can be called via command line (i.e. as part of a bigger system).
> 
> Quite rapidly I entered into "context hell" trying to figure out the
> proper context to call "bpy.ops.graph.select_all_toggle();
> bpy.ops.graph.sample()".
> The answer to this was "the_scene.objects.active = the_object;
> bpy.context.area.type='GRAPH_EDITOR' " (found by someone in the IRC 2
> hours after my first attempt).
> 
> The key problem now is that when running via   "blender --python
> script.py" bpy.context.area is None, this seems to be a consequence of
> bpy.context.window being None.
> 
> > From what I could gather in the IRC, no one is aware of a method to
> create a new window (or setup properly the bpy.context.area) from
> python.
> In this case the documentation is of no help (it does not even mention
> bpy.context.area).
> 
> Being able to launch automated tasks via "blender --python script.py"
> seems like a natural usage of this feature, and has multiple use
> cases.
> 
> Does any one have a suggestion/idea on how we could make this work ?
> 
> Thanks for your input.
> Best regards,
> rodrigob.
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20120502/7b5eabab/attachment.html>


More information about the Bf-python mailing list