[Bf-python] Layer handling inconsistant

Gilbert, Joseph jgilbert at tigr.org
Mon Apr 18 16:53:44 CEST 2005


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().
Although the 'bitflag' XOR approach may not be the best way to tackle setting object layers because there is no way to unset a visible layer (is this right? :)) It looks like [base->lay = local | newLayer;]  only allows you to set a layer but you need a &=~ to unset the layer somewhere. 
Anyway.... :)

-----Original Message-----
From: bf-python-bounces at projects.blender.org [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell Barton
Sent: Sunday, April 17, 2005 9:31 PM
To: Blender Foundation Python list
Subject: [Bf-python] Layer handling inconsistant

At the moment Window.ViewLayer() and object.later use a different type of variables and therefor cant be interchanged.

ob.layer is a flag and Window.ViewLayer() is a list
There realy shouldent be any issues with
I want me new object to be on the current visible layers, or - change my object to the visible layers.

At the moment I have got around this by converting  this list into a flag.

    # Get the layer flag, this should realy be a part of blender.
    layerFlag = 0
    for l in Window.ViewLayer():
        layerFlag |= 2 ** l-1 # Get the flag of the layer index
    ob.layer = layerFlag

Mabe there needs to be a flag option for ViewLayer
Window.ViewLayer(flag=1)

Is this acceptable?
- Cam



More information about the Bf-python mailing list