[Bf-committers] re: Python and layers

Campbell Barton cbarton at metavr.com
Mon Oct 9 16:18:52 CEST 2006

Thanks Matt, this makes more sense now.
Im not sure what the solution should be..

scn1.Layers= scn2.Layers should never raise an error IMHO. so maybe let 
the user effect the next 12 bits?

That or allow the users to set it but  dont apply the setting of the 
last 12 bits.
that means after scn1.Layers != scn2.Layers  which could be confusing :/.

Whats might mess up if  a scene took another scenes layers bits.?

Matt Ebb wrote:
> Funny you guys mention this, I ran into a similar problem earlier with 
> the 3DS importer choking when I had all layers enabled. I was going to 
> mention it but I was without internet at the time and forgot.
> Anyway, at least in my case I think the 'problem' (or at least the 
> possible solution) is in Blender itself. As you guys would know, the 
> layers int in blender is abused for more than just layers, which 
> complicates things.
> However, when you press ~ to enable all 3D View layers, it actually 
> does more than that, it sets every bit in the layers int to 1. This is 
> bad behaviour, since when a user is pressing ~ they mean to show all 
> the 20 3D View layers, they don't mean to mess with the other 12 flags 
> for local view or whatever it is. When python checks to see if all 
> layers are enabled, it's just looking at the 20 layer bits as it 
> should, and not the extra ones. So python was comparing the int that 
> should be when 20 layers are set to the number that is actually there 
> after you press ~ in Blender (which is much higher) and found that 
> they mismatch, giving an error. From memory, manually clicking all the 
> little layer buttons to set them on worked, which confirms this theory.
> Anyway, hope this info is useful to the current situ, and sorry for 
> not reporting earlier!
> cheers
> Matt
> On 09/10/2006, at 23:43 PM, Campbell Barton wrote:
>> Alexander Ewering wrote:
>>> On Mon, 9 Oct 2006, Campbell Barton wrote:
>>>> campbellbarton (Campbell Barton) 2006/10/09 06:29:24 CEST
>>>>  Modified files:
>>>>    blender/release/scripts image_billboard.py
>>>>    blender/release/scripts/bpymodules BPyRender.py
>>>>    blender/source/blender/python/api2_2x Scene.c
>>>>  Log:
>>>>  BPyRender.imageFromObjectsOrtho's now sets all layers visible,
>>>>  an error in Scene.c - scn.Layers disallowd all layer bits to be set.
>>> The error is not in Scene.c, but in BPyRender.py, which tries to 
>>> enable 21
>>> layers instead of 20.
>>> To avoid such confusion, I would suggest replacing arbitary *decimal*
>>> numbers which don't mean a thing with things such as (1 << 20)-1, or
>>> at least 0xfffff.
>> are you sure? - if you enable all layers and then print them the 
>> scn.Layers the number it spits  out is 2097151

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

More information about the Bf-committers mailing list