[Bf-python] Implementing bpy.classes

Campbell Barton cbarton at metavr.com
Wed Jun 27 20:41:54 CEST 2007


Ken Hughes wrote:
> Campbell Barton wrote:
>> Willian Padovani Germano wrote:
>>   
>>> Hi Ken,
>>>
>>> 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?
>>>>       
>>>  From what I understand, bpy.classes will only include object types. So, 
>>> for Blender objects, it's only the bpy object defined in Object.c, not 
>>> the Blender.Object module functions and constants (that should be moved).
>>>     
>> I had to re-read this 3 times to get it ;) - object can mean 4 things. 
>> blender object, PyObject, blender object module or blender PyObject 
>> object type.
>>
>> Agree, its only for types and not for module functions, we still need to 
>> deciede where they go. Blender.Object.Duplicate() for instance.
>>   
> 
> Ok, so maybe one of you will break it down for me, as I'm still confused 
> about what is an object and what is an object.  Show me the *exact C 
> code* we're talking about.
> 
> For what it's worth, I've tried this:
> 
>     PyObject *module = Py_InitModule3( "bpy.class", NULL, "The bpy.class 
> submodule" );
>     PyObject *obj = (PyObject *)&Object_Type;
>     PyModule_AddObject( module, "Object", obj );
> 
> which gives me a "<type 'Blender Object'>", but haven't been able to add 
> PyObjects (like constants) to obj using the standard Python C API.
> 
> Ken

That was the thing I was unsure of, and if its not possible I guess this 
is python telling us to do it a different way.

Antont was saying its something he's not seen before.
Im not against a bpy.constants or looking at other alternatives still.



More information about the Bf-python mailing list