[Request for Document]Which operators use which context

I badly need documents on how each bpy.ops.Operators uses the bpy.context keys.
Currently it requires either trials and errors or reading the source code, which is a nightmare for developers.

It’s a pretty bad situation, though it’s not very likely to be fixed anytime soon.

Operators should be avoided as a programming API, they are end users tools that have unpredictable side effects and can change behavior often. Whenever possible it’s better to read/write the data structures directly.

I strongly agree that Operators is not the best way to manipulate blender. However, the info bar and mouse hover show the Operators, so it is likely to be used by occasional users.

I also believe that the bpy.context.copy() itself should be more sophisticated. Here sophisticated means,

  • do not expose object_base
  • add objects to “selected_objects” if it is in “selected_editable_objects” and so on

I made a simple mock-up for this paste and run at the internal-text-editor

Sample code (in the main());

c = ContextEditor()
c["selected_objects"] = []
c["object"] = bpy.data.objects["Cube.001"]
bpy.ops.object.origin_set(c.rc,type='ORIGIN_GEOMETRY')
  • The user instantiates the ContextEditor and edit it via dict-like access.
  • c["selected_objects"] = [] will clear not only selected_objects but also bases and other related ones.
  • c["object"] = Object will also set keys like active_object and selected_editable_bases.
  • To pass ContextEditor as an override_context, the user uses the rc prop