Best way to save properties inside Blender?

I am currently saving script properties to files externally. Unfortunately, ctrl-z undo closes scripts so I lose all the changes if I don’t save often enough. So I could use a way to save data internally in a .blend file but preferrably in such a way that won’t affect the file opening in future versions of Blender.

I looked at the game properties but I don’t think that’s what I need - I could convert the data to the supported property types but it would be easier if I could save the data direct and also not on an object by object basis (though this actually might be quicker). What limitations do game properties have? I have a couple of internal data structures that contain buttons, lists, dicts, custom classes etc.

The Registry class seems to save a property/key that is global to all .blends but I want each .blend file to have it’s own unique set of properties.

Even if I could store my save file inside the .blend object that would be ideal - it just saves me having to remember a separate file when transporting a .blend. All I would need is something that can store a whole bunch of strings e.g. one per line of my file.

You could use an IdProperties subgroup to hold all your data inside the blender file, but it sounds like you may have alot of data and might be better off just specifying the path to an external file(maybe a pickled file) in a Scene idproperty, then call on your data through a scene scriptlink.

Thanks, I wasn’t aware of IDProperties. It looks like just what I need:

http://wiki.blender.org/index.php/BlenderDev/ID_Property#Python_Tutorial

I can specify group properties for my dicts, which should save me parsing the data. I’ll have to see if it supports all the types I use but it should be fine. :cool:

I’m using blender’s internal file (Blender.Text) to store my script’s data. It’s combined with autosave when data are changed. It’s very easy to use - I just pickle data that have to be stored and save them to Text object.

Hmmm, I’m not sure which way to go now. I just plugged the Blender.Text method into my script and it seems fast enough - I tested storing quite a lot of data (around 2,500 variables) and it managed it in 0.7 seconds average. However, I could see it exceeding that amount. 100 objects, 25 variables each = 2500.

I got a message a few times saying I had filled up the undo buffer too, which happened frequently enough to be annoying.

I like the Text method because it keeps all the info in one place if I need to modify or clear it. However, on a big data set, it could slow down my script. One huge advantage it has is I can load it in easily from another .blend file by appending.

Per object properties will be much faster though and I’d be able to auto save those but it would be hard to import them into another file. However, I shouldn’t have to change the data into text, the properties would likely support the data types I use (at least the object ones) and I can always make an import/export function to get data from one blend to another.

osxrules,
you can also create separate Text object for every object you need to store properties. Then you update only changed objects - few Text objects at once, not whole data set.

I decided to use properties but all I do is store the entire set of data at once into a single scene property.

This is pretty quick as I just convert it all to a string in one go and it keeps all my data in one place. I could probably have used a Text object for this but this way I don’t get buffer warnings and I can give each scene its own properties.