[Bf-python] Partial proposal for armature+bone modules

Willian Padovani Germano wgermano at ig.com.br
Wed May 28 06:21:40 CEST 2003


On Tue, 2003-05-27 at 12:00, Jordi Rovira i Bonet wrote:
> If I return Py_None when there's no parenti get an "attribute error" at 
> runtime, so there must be a way to check for the parent first. I've 
> decided to add a "has_prent query, and raise an error when asked for the 
> parent of an object that hasn't, thus removing the wrapping of NULL bones.

Raising an error doesn't seem the right approach.  That's what None is
for.  You ask for the parent, there's none, None is returned.  A simple
related ex. in Python is with empty dictionaries:

d = {}
a = d.keys() # a is [], the equivalent of None for tuples/lists
if not a: print "Dictionary is empty"

In python we'd expect something like:

dad = a.getParent()
if dad: do_something(dad)

and not an error.  Not that there shouldn't be a .hasParent() or
.has_parent() method, that's a useful addition (has_prent sounds
strange, though, better keep names more recognizable when possible).

> This is what i meant when i said i forgot something... :) I'll do it 
> right now.
(...)
> This was a way to test during development, this condition is impossible 
> now, won't damage. It's not a way to control "user errors" :)
(...)
> >The pointer comparison is already done, for example, in Camera.c
> >
> I know, i suggested it :).

Ok : ), I was just reading your code and commenting to show you I really
looked at it ; )...

> I've added a function to the NMesh module called "getVertexInfluence" to 
> query for the a list of bone and weights pairs influencing the vertex. 
> This is readonly and should be enough to write exporters. I've done it 
> based on the other functions to keep coding style. Is this going to go 
> to the cvs?

Ok, that's good : ).  You can send me the function and I'll add it to
the NMesh module.  Yes, this and your whole armature/bones code should
be in cvs, when you feel it's ready to be committed.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list