[Bf-python] Attribute casing
Joseph Gilbert
models at paposo.com
Fri Aug 19 05:18:43 CEST 2005
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.
Just an idea :)
Ken Hughes wrote:
> Yehoshua Sapir wrote:
>
>> Gilbert, Joseph wrote:
>>
>>> Yes correctNorMap sounds like it should be correct for the texture
>>> button. Col, Nor, etc are part of a bit toggle regarding
>>> mtex->mapto. These should be module constants. Col, Nor, Var are
>>> attributes that relate to
>>> mtex->colFac, mtex->norFac, and mtex->varFac attributes of the Mtex
>>> struct.
>>>
>> My patch avoids exposing the bitfield to the Python scripter and
>> instead provides Python Booleans. (For example, there's a
>> correctNorMap attribute that gives you True or False rather than
>> having to do math with some bitfield and a constant.) The interface
>> is a lot nicer IMO. Anyway, because of this, I have separate
>> variables for the map to buttons.
>
>
> I think this is a good approach to making the BPython API resemble the
> UI as much as possible. In fact, I was prepping for "tp_getset-ing"
> sceneRender.c (Blender.Scene.RenderData) and noticed that Joseph had
> done this for the myriad of button in the Scene UI. (Plus he had a
> nice generic bitfield manipulation procedure which I modified slightly
> and put into gen_utils.c) So while I'm adding new atributes to
> modules, can I get a consensus that I also implement enable/disable
> attribures for bitfield access?
>
> Ken
>
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>
>
More information about the Bf-python
mailing list