[Bf-python] A Blender.Struct module?

joeedh joeeagar at prodigy.net
Fri Nov 5 03:05:44 CET 2004


Hi.  Python has this really nice module called the "struct" module, that 
lets you save basic python types as C structs within a binary file.  
What if we made a module that would let users save basic python types 
within a .blend file? 

Such a module would have it's own implementation of Struct-DNA, which 
means that the C struct format string would have to be pretty detailed, 
e.g. "Foo { int a; int b}" would make a struct Foo with int members "a" 
and "b" (unlike python struct's format string, which I believe would 
simply be "ii").  This module would store all data within a list, each 
struct contained within a special struct, like so:

typedef struct  _PythonStruct {
    int len; /*structure len*/
    char name[23]; /*the struct name*/
    void *struct; /*a pointer to the actual struct*/;
    char *formatstr; /*a format string saying what the struct is*/;
} PythonStruct;

to facilitate saving the data in a .blend file.  This struct would be 
processed by makesdna.

joeedh
P.S.: And if this doesn't make sense, go to 
http://docs.python.org/lib/module-struct.html

joeedh



More information about the Bf-python mailing list