[Bf-python] Proposal to getSelected and getAcitve

Stephen Swaney sswaney at centurytel.net
Thu Mar 3 05:16:27 CET 2005


On Wed, Mar 02, 2005 at 02:13:34PM -0500, Mark Potse wrote:
> 
> I will try to contribute documentation for the code
> that you submitted.  Therefore I would like to understand
> why you put this in the Scene submodule rather than the
> Object submodule. What is the distinction between the 
> two? Is the "object selection" independent of the scene
> while the "active object" is a scene property in Blender's 
> philosophy?

It has to do with the structure of the bleneder database, which is
what we are actually manipulating here.

Each Scene can have its own active object and set of selected objects.
Object.GetSelected() was designed as a user-perspective method to make
the selected objects in the current scene ( what you see in your 3d
view ) available for manipulation by bpy scripts.  There is trickery
involved as it does not depend solely on an object but also looks
at scenes and layers.

Note: if there are selected objects, the active object is the first
one in the list returned by Object.GetSelected().

> In addition I propose to name it Scene.GetObjects() (plural).
> This stresses that the function returns a list of objects.
> The name that you gave it, Scene.GetObject(), suggests that
> it returns one object.

Plural is better.  Bpy naming convention calls for getObjects() since
this is an instance method and is bound to a particular scene.
Example:

  scene = Scene.Get( 'some_scene')
  ob_list = scene.getObjects()


> On 02-Mar-2005 Joilnen Batista Leite wrote:

> > In first I changed isSelected to test all objects in
> > ever scene,

This changes the meaning of Object.isSelected().  Right now, it tests
objects in the current scene.  We can not break existing scripts.

One way to get the effect you want is to add an optional scene arg.
However, I am not convinced this belongs as an Object method rather
than a Scene one.

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list