How to save self created Properties?

Hey there…
I have following problem. I have created a ui element which can generate me properties!

The button is an operator that creates a property with following command:

bpy.types.Object.myprop = bpy.props.StringProperty(default=“Hello World”)

So everything works fine! The property gets registered and created. It also shows up in the ui where I want it!
I thought such properties get saved, but that is not the case. After saving and loading the blendfile, the property is gone!
Does anyone know how to save such a property within the blendfile?

thanks for your answer.
I have prepared a simple blendfile that illustrates my problem. Yes, I do assign the property to my object. And I also get the property under custom properties.
But what I loose is the bpy path to my property.

customProp.blend (383 KB)
Just run the script in the blendfile. Property appears under “custom properties” and can be accessed via bpy.context.active_object.my_prop. Save it. Important: Now close blender, and than start the blendfile again. Under “custom properties” the property is still available, but not under bpy.context.active_object.my_prop

Using 2.65a It seems to be working as I would expect it to. I changed the value from 15 to 17, saved the file and exited Blender. When I reload the file I see 17 in the 3D viewport properties (N-KEY panel) and under the object context of custom properties.

Relying on the context to be correct may be the problem. Try fetching the object by name rather than by context.

ob =

This did seem to work, however.


yeah… the thing is, I need the update function! I am building up a system where I can add Custom Slider in my ui. This are hooked up to automatically generated shapekeys that can be controlled by my sliders.
And to sync the shapekeys to my sliders I am using an update function!

Here is a blend where I have only put the most important stuff in!
I have a draw Class for the ui.
An add Slider operator. This one creates a custom Property and a shapekey and hooks them together.
And an update Slider operator that is called within my custom property!

I can add properties. Everything works fine! But after restarting, my ui class throws errors, because my props are gone!

addSliderTest_02.blend (510 KB)

Ok, I have solved my problem now!
I have an init function that is executed on load! This goes through my custom created slider_list group property! And recreates the slider on startup. I save name and value in my slider_list.