API

Creating Blender Add-ons variables with values saved in blend-files

All user-defined classes (panels, operators), registered in Blender API, exists only during Blender runs. After program close they are deleted from memory. Therefore, if some variables are defined in user classes, all of them will be reset after Blender restart.

However, sometimes it is necessary to use in Blender add-on variables with values that not be lost in the process of program restarting. To retain variables values, it needs to wrap them into special class – property, and attach to any object whose properties are stored in * .blend file.

Variables in Blender API operator classes

User defined operator classes, inherited from bpy.types.Operator, are static. Accordingly, only static variables can be defined in them.

Static variable sampleVar definition in SampleClass class: