[Bf-python] Proposal to getSelected and getAcitve

Stephen Swaney sswaney at centurytel.net
Fri Mar 4 15:50:29 CET 2005


On Thu, Mar 03, 2005 at 01:27:28PM -0300, Willian Padovani Germano wrote:
> 
> There's already:
> 
> - Object.Get() to get all objects in the current scene;
> 
> - Object.GetSelected() to get all selected objects in the current scene 
> (this function uses G.vd and we probably don't need to -- and most 
> probably shouldn't in fact -- so we can consider removing mentions to 
> G.vd there).  It's possibly not needed to check if the active object is 
> in an active layer, too and so we don't have to check for G.vd->lay 
> either).  .GetSelected() also serves to get the active (selected) object.
> 
> Campbell is right, the active object may not be selected (if no object 
> is selected).  But isn't it better to only allow access to an active 
> object if it is selected?  This gives a clear, well defined and 
> *reliable* way to access the active object.
> 
> - We can also already change scenes and set visible layers, so there's 
> no need to add new functions to mess with this, it can be done via 
> Python cleanly.  Maybe expanding Object.Get and Object.GetSelected with 
> an optional 'layers' list parameter to restrict the returned obj lists 
> to only the given layers can be useful, but again, this is already 
> possible via bpython in more verbose ways.
> 
> Setting the active object is already done with method object.select(): 
> select an object and it becomes the active one.
> 
> Still, we can add Object module functions Object.SetActive(obj) and also 
> Object.GetActive() like Campbell suggested, for completeness and 
> simetry, since other modules have these.

Nice job of cutting through the fog, Willian!

Part of the confusion, I think, comes from the fact that being part of
a selected set of objects in a scene is not a property of either
Object or Scene, but a relation between the two: IsSelected( scene,
object ).

I agree with you that .get/.setActive() might be nice additions for
completeness.  

I also agree that the other proposed functionality is already
available either with existing methods or by using list
comprehensions.  The current Object.GetSelected() interface mimics the
way an interactive use selects and modifies objects.

My personal preference is for APIs that provide a toolkit that can be
combined for a task rather than creating every possible combination of
methods with complex, or cryptic argument lists.  

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list