[Bf-python] Object Properties from Python?

Jonathan Merritt j.merritt at pgrad.unimelb.edu.au
Thu May 27 07:43:28 CEST 2004


Thomas A Dyar wrote:

>The property system could be useful for exporters, but my code should be
>extended to "set" as well as "get" property values, and also physics
>properties. Shouldn't be that much work, and I think there should be a module
>for it.
>  
>

Absolutely!!! :-)  On this topic, there has been a little discussion 
from those of us looking at the problem of RenderMan export via Aqsis.  
We have thought that the ability to store an arbitrary Python object 
within each Blender object is probably the best way to store the 
(potentially VERY large amount) of assigned information that might be 
useful to the RenderMan renderer.

(eg: Some properties that may wish to be assigned on a per-object basis:
- Surface shader name (a string).
- Shader parameters ((string,value) tuples, or a dictionary thereof).
- Shading rate (a float).
- etc...)

Perhaps it might be more useful to allow a *single* PyObject to be 
assigned to each Blender object?  Then, strongly-typed assignments (such 
as we have now in the logic window) could be handled by a special 
internal dictionary.  To implement more complicated behaviours we could 
use a second dictionary of Python classes that sits within the top-level 
PyObject.  The C code could then automatically handle pickling 
(serialisation) of the PyObject dictionarys into the .blend file, 
provided that they provides the necessary hooks.  That would make things 
much easier than having to handle things like that from within a Python 
script, and using a separate storage area that is not part of the .blend 
file.

What are people's thoughts on this?

Jonathan Merritt.



More information about the Bf-python mailing list