[Bf-python] Attribute casing

Ken Hughes khughes at pacific.edu
Fri Aug 19 16:06:08 CEST 2005


Joseph Gilbert wrote:
> It seemed like a nice system for the Render module because most buttons 
> in the UI were toggles for bits. However it does leave a few things to 
> be desired - such as the abilty to 'get' the value of a bit rather than 
> just setting the bit. Combined with attributes it might work nice for 
> individual bits. i.e. you could have a 'blah' attribute who's setter 
> calls the bitToggle function in genutils and who's getter gets the value 
> and returns a bool. This works nice on single toggles.
> e.g. object.attribute = blender.TRUE
> (this is a call to the toggleBit function)
> or
> if object.attribute: (calls the getter)
> ...do x
> For attributes that take a group of bits i.e. something that takes more 
> than TRUE/FALSE -  it might be better to get/set a list of 
> BPy_Constants. The setter for such could parse the list of constants and 
> then call the bitToggle(true) for each constant passed, while the getter 
> would return a list of constants maybe.

So we would provide two ways to access bitfields:
(1) multiple arguments to directly manipulate the bitfield (i.e, 
material.mode = [bit0, bit1, bit2, etc] or material.mode = bit0 | bit1 etc)
(2) single arguments to indirectly manipulate one bit in the bitfield 
(i.e, material.halo = true)

The first method is convenient when user wants to affect multiple 
changes at once (and is "backward compatible" with most modules existing 
now) and the second method is convenient when you just want to handle 
single settings and don't want to remember which bit is it.

Ken



More information about the Bf-python mailing list