[Bf-python] Implementing bpy.classes

Campbell Barton cbarton at metavr.com
Tue Jun 26 23:15:56 CEST 2007


Ken Hughes wrote:
> Ken Hughes wrote:
>> I was going to start adding the new constant handling code to the pyapi 
>> branch, but since constants are supposed to be available through the 
>> bpy.classes module, I need to start implementing some of that too (I 
>> guess).  But what does this module really contains?
>>
>> For example, assume we have bpy.classes.Object.  Is this just the BPy 
>> Object type?  I.e, if you write:
>>   print bpy.classes.Object
>> should it just say
>>   <type 'Blender Object'>
>>
>> Or is "Object" a new type of BPy container which for now has constants 
>> for that class, possibly constructors or other things later?
>>   
> Or, this just occurred to me: is it basically the same thing as the 
> Blender.Object module, except with some or all of the module methods 
> removed?
> 
> Ken

I think it should be PyType of Object, (PyObject *)Object_Type

for this to work we need to provide a /* initproc tp_init; */ for each 
type and then add constants to its dictionary.


This means you can do

ObType = type(bpy.data.objects['Cube'])
new_ob = ObType()

We could enforce arguments also - like object data or the scene for instance

(I think object data is a must, scene could default to the current scene)

Some types should raise an NotYetImplimented error on initialization - 
like sounds and fonts.



More information about the Bf-python mailing list