[Bf-python] Mesh Layers

Martin Poirier theeth at yahoo.com
Wed Dec 13 03:15:41 CET 2006


--- Campbell Barton <cbarton at metavr.com> wrote:

> for people who dont read the CVS logs, heres some
> additions that may need some looking into.
> 
> Variable names an functionality 
> 
> exposed CustomData_get_active_layer_index in
> BKE_customdata.h (needed by python to get the active
> layer)
>   
>   added python api stuff to deal with Color and
> UV/Image layers.
>   
>   me.activeUvLayer - int
>   me.activeColorLayer - int
>   me.totUvLayers - int
>   me.totColorLayers - int
>   
>   me.addUvLayer()
>   me.addColorLayer()
>   me.removeUvLayer()
>   me.removeColorLayer()
>   
>   Variable names may need changing.

You should capitalize the Vs in UV. It's a coordinate
system, not word, so case doesn't apply as it does to
other words. Also, please use total, not tot.
Obfuscating a name for two letters is not worth it.

activeColorLayer and activeUVLayer are read/write I
assume?

If no layers are present, active should be -1. (it
would follow the Python convention for absent
indexes). 

Trying to set the active values to anything out of the
usable range should raise a ValueError.

Any change to the active values for mesh with no
layers should raise an error (that is implied by the
previous suggestion, but maybe the error message
should be different).

> At the moment adding always makes a new layer at the
> end array and removing always removes the active
> layer.

removeUVLayer(index) and removeColorLayer(index) (with
index default to current if absent) would be nice.

(although in this case, remove is not usually used
with index, pop has no place here I think, since the
layer is not returned)

When removing the current layer, should be changed to
the following one (following iterator logic, IIRC),
looping back to the first one if the last one is
removed.



-------------

Just a thought, wouldn't it be better to have layers
object instead? With access like that:

me.UVLayers  -> layers object
len(me.UVLayers) -> total (PySequence_Length)
me.UVLayers[n] -> access to layer n
(PySequence_GetItem)
del me.UVLayers[n] -> remove layer n
(PySequence_DelItem)
me.UVLayers.active = n -> set active layer to n
(custom method) 

All other methods of the sequence protocol should
fail.

Opinions?

Martin


 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com



More information about the Bf-python mailing list