[Bf-python] A Blender.Struct module?

Yann Vernier yann at algonet.se
Fri Nov 5 12:20:20 CET 2004


On Thu, Nov 04, 2004 at 06:05:44PM -0800, joeedh wrote:
> 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? 

Not C structs, really, but binary data. They happen to be the same
sometimes, but the struct module is considerably more flexible, with
features like byteswapping and precise control over padding. The struct
module is one of the essentials, and like zlib should be bundled where
Blender comes with its own Python.

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

You essentially wind up with a BLOB interface for the Blender dna
format. I'm not sure how often this is really useful. Currently I've
been storing things in Text objects, which isn't very elegant either,
but can at least be recovered by people who don't have access to my
code. Can you think of a use case?

-- 
PGP fingerprint = 9242 DC15 2502 FEAB E15F  84C6 D538 EC09 5380 5746
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20041105/640d31c8/attachment.sig>


More information about the Bf-python mailing list