save user data in blend file?

Hi,

I like a script to save some user data into the current open blend file. Is there a special data structure for this? Another idea is to create an empty somewhere and write the data into this object. But I think there’s better solution…

regards
Andreas

https://blenderartists.org/forum/viewtopic.php?t=14355#122757

I think you can do something like this:

write_data.py

import Blender

var = 'blablabla'

filename = 'user_data'

newfile = Blender.Text.New(filename)
newfile.write(var)

read_data.py

import Blender

filename = 'user_data'

datafile = Blender.Text.Get(filename)
new_data = datafile.asLines()
print new_data[0]

Check out the Text module:
http://www.blender.org/modules/documentation/236PythonDoc/Text-module.html

No, no no. there is a wiser way to save user data. use the internal .blend dictionary.
It’s called registry:
http://www.blender.org/modules/documentation/236PythonDoc/Registry-module.html

The registry isn’t saved, however. Once you quit blender it goes aways, and it isn’t re-initilized when you open new files, either.

joeedh

The registry is saved in the blend file. It’s for case where the script is keeping data usefull to the current project. To save general data used in all .blend file, you can save/load from a text file in the bpydata folder. There is now toolsl to do so in the current cvs version.