Python can now run operators with their own context (data context).
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 09:25:11 +0000 (09:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Oct 2009 09:25:11 +0000 (09:25 +0000)
commitc508e6198a614619bb9d82cd59c0fdb7f55f427d
treebda1b4de7fbc1ef951f4bf49dfd440086902613a
parent40731af9d0b85e3cf93e46e48b814faa06aac74b
Python can now run operators with their own context (data context).
The aim of this is to avoid having to set the selection each time before running an operator from python.

At the moment this is set as a python dictionary with string keys and rna values... eg.

C = {}
C["active_object"] = bpy.data.objects['SomeOb']
bpy.ops.object.game_property_new(C)

# ofcourse this works too..
bpy.ops.object.game_property_new({"active_object":ob})

# or...
C = {"main":bpy.data, "scene":bpy.data.scenes[0], "active_object":bpy.data.objects['SomeOb'], "selected_editable_objects":list(bpy.data.objects)}
bpy.ops.object.location_apply(C)
release/scripts/modules/bpy_ops.py
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/intern/context.c
source/blender/makesrna/intern/rna_curve.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_operator.c