[Bf-taskforce25] Operator PyAPI

Brecht Van Lommel brecht at blender.org
Wed Dec 3 20:09:09 CET 2008


Hi,

On Wed, 2008-12-03 at 14:36 +1100, Campbell Barton wrote:
> This could work, but I still think its useful for python to be able to
> optionally have its own context.
> * Some tools would benefit from python working in the user context directly.
> * Other tools youd want to copy the context - use it then throw it away.
> * In cases where you want to use an editmesh and edit armature at once
> you might want access to 2 contexts without having to switch modes
> every time (as the user may want 2 screens, with 2 objects in editmode
> at once)

I think that ideally, for this type of operation with an editmesh and
editarmature you don't really want a context. I would prefer meshes,
armatures, etc to get an ->edit pointer, which can be created or
removed, not having this as something that has to change the context.

> So if commands have an automatic context, it would be good if python
> could set the active context thats used, as opposed to always making
> sure the active context is in the mode needed for each operator to
> run.

Sure, python should be able to set context like other C code, especially
for drawing code. For operator code I'm not so sure too much context
manipulation is a good thing. When possible I think it is better to do
operations on objects that you have, rather than using the context too
much for this, as state machine type code is a bit messy. Though it does
lead to the question if operators should somehow be available as object
methods, but maybe there can be a trick to do this semi-automatic.

Brecht.



More information about the Bf-taskforce25 mailing list