You can side step context-hell for ctypes-hell if you call blender's C-API directly using "libblender" and its ctypes wrapper. Here is a quick look: http://code.google.com/p/libblender/source/browse/tests/creator.py
-brett- On Wed, May 2, 2012 at 10:33 PM, Rodrigo Benenson < [email protected]> wrote: > operators are in play... > > regards, > rodrigob. > > On Wed, May 2, 2012 at 4:22 PM, Bassam Kurdali <[email protected]> wrote: > > 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 > > <[email protected]> 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 > >> [email protected] > >> http://lists.blender.org/mailman/listinfo/bf-python > > > _______________________________________________ > Bf-python mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-python >
_______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
