[Bf-python] Layer handling inconsistant

Campbell Barton cbarton at metavr.com
Wed Apr 20 05:06:06 CEST 2005


Heres a solution!
the visibleLayer is a property of the scene, each scene has its own 
visible layers, just checked.
Keep Window.ViewLayer(), just add the layer flag as class variable to 
the scene.

scn = Scene.GetCurrent()
ob.layer = scn.layer

- We should realy be adding scene spesific stuff, rather then global.
- Cam



Campbell Barton wrote:

>
> >From python object docs
>
> *The object layer. This value is a bitmask with one position set for 
> each of the 20 possible layers starting from the low order bit. The 
> easiest way to deal with these values in in hexadecimal notation. 
> Example: *
>
>* ob.Layer = 0x04 # sets layer 3 ( bit pattern 0100 )
>*
>
>
> So ob.layer is a flag, and objects can Exist on Multiple layers (Try 
> moving to another layer with M pressing shift while selecting multiple 
> layers)
>
> The flag is what blender uses internally, I have become used to using 
> binary logic in python- and it seems you need to be when python 
> functions are returning flags.
>
> There realy needs to be a way to get the view flag of the active 
> layers, having the user generate the flag themself is realy dumb.
> - Cam
>
>
>
> Joseph Gilbert wrote:
>
>> Hehe.  Well ViewLayer() returns the list of visible layers and 
>> ob.layer shows the layer the object is visible on (i didn't write 
>> either of these O:-)  ) You can't do a ob.layer = ViewLayer(). 
>> Doesn't make sense. Objects need to be on a single layer. (correct me 
>> here if i'm wrong). If what you want is a test to see which layer is 
>> visible and move and object to it, you need to test for ob.layer in 
>> the list returned by Window.ViewLayer(). Right?
>>
>> if ob.layer in Window.ViewLayer():
>>   ob.layer = Window.ViewLayer()[0]
>>
>> or something should work right?
>>
>>
>> Campbell Barton wrote:
>>
>>> Stephen Swaney wrote:
>>>
>>>>On Mon, Apr 18, 2005 at 10:53:44AM -0400, Gilbert, Joseph wrote:
>>>>  
>>>>
>>>>>ob.layer takes a single int as input. It looks like you want to set the ob.layer to a list of ints returned by viewLayer(). I think the best way to implement this is to have ob.setattr to parse a sequence instead of an "int" value. (see vector() in mathutils) That way ob.layer will accept a single int or a list of values. This approach would allow you to do ob.layer = ViewLayer().
>>>>>    
>>>>>
>>>>
>>>>I would rather see overloaded argument lists like this than flags to
>>>>change the return type of a method.
>>>>
>>>>  
>>>>
>>> I dont think its ideal for have ob.layer accepting both formats of 
>>> layers is ideal.
>>> What if they want to see of the object is equel to the view layers?
>>>
>>> if ob.layer != Window.ViewLayer(): # Would Not work
>>>
>>> would need to do
>>>
>>> oldlayer = ob.layer
>>> ob.layer = Window.ViewLayer()
>>> visLayer = ob.layer
>>> ob.layer = oldlayer
>>> if oldLayer != visLayer: # This would work.
>>>     .....
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>Bf-python mailing list
>>>Bf-python at projects.blender.org
>>>http://projects.blender.org/mailman/listinfo/bf-python
>>>  
>>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Bf-python mailing list
>>Bf-python at projects.blender.org
>>http://projects.blender.org/mailman/listinfo/bf-python
>>  
>>
>
>
>-- 
>Campbell J Barton
>
>133 Hope Street
>Geelong West, Victoria 3218 Australia
>
>URL:    http://www.metavr.com
>e-mail: cbarton at metavr.com
>phone: AU (03) 5229 0241
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Bf-python mailing list
>Bf-python at projects.blender.org
>http://projects.blender.org/mailman/listinfo/bf-python
>  
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20050420/335989a5/attachment.html>


More information about the Bf-python mailing list