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

Jordi Rovira i Bonet jordi.rovira at ima.udg.es
Wed May 28 11:38:12 CEST 2003


Willian Padovani Germano wrote:

>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)
>  
>

Agreed. It was my mistake: when i tried to implement it returning PyNone 
i got an "attribute error" and i deduced that this was fired when 
returning PyNone to python, but it was caused by the ending code in 
GetAttr callback. Now it's fixed, and i think we could avoid the 
hasParent query to simplify code and interface.

>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).
>
Agreed, "has_prent" is a typo in the mail, sorry. Function name is 
actually "hasParent()".

I attach a small patch and 4 files in a .tgz that should be enough to 
add the armature support to the code. The patch has to be applied from 
source/blender/python with -p0. I think its ready for testing

(bandoler)

P.S. I've found that the getType function is not implemented in 
Object.c, is there another way to check for the type of an object or it 
will be implemented in the future? I'm having trouble with the Object 
module, necessary to test the armatures (need to get the parent and 
types...)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: armature.tar.gz
Type: application/x-tar
Size: 8460 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030528/b6aef219/attachment.tar>


More information about the Bf-python mailing list