3
$\begingroup$

I would like to save a temporary Boolean value on bpy.types.Scene that exists only as long as blender is open. When you close blender and open it back up the variable should be set to False.

The only way I can see to do this is to store the variable in a dictionary and store a reference to the variable on the scene. Then when you open blender the reference will refer to nothing, at which point the variable can be re-created with the default value.

Is this the only way to accomplish this, or is there a better way?

$\endgroup$
8
  • $\begingroup$ Have you looked at on_load handlers? blender.org/api/blender_python_api_2_75_release/… $\endgroup$
    – batFINGER
    Commented Sep 18, 2015 at 23:54
  • 1
    $\begingroup$ Does it have to be bpy.types.Scene what about bpy.types.WindowManager $\endgroup$
    – batFINGER
    Commented Sep 22, 2015 at 20:03
  • 1
    $\begingroup$ I didn't realize that about the window manager, thanks! Unfortunately, I'm using a property group so window manager would require storing data in two places. Not the end of the world, but I'd prefer keeping everything in the property group. $\endgroup$
    – Isaac
    Commented Sep 24, 2015 at 2:34
  • 1
    $\begingroup$ @WindUpToy my understanding is that the window manager is created per session, so it's not saved in the file (that seems to be the case, but I don't know for sure). Also, I'm pretty sure SKIP_SAVE only applies to operator properties (i.e. whether or not what the user adjusts should be the default the next time the operator is ran), the documentation is definitely lacking in that area. $\endgroup$
    – Isaac
    Commented Dec 31, 2017 at 5:17
  • 2
    $\begingroup$ @WindUpToy This confirms my answer to both questions: blender.stackexchange.com/a/8443/2387 $\endgroup$
    – Isaac
    Commented Dec 31, 2017 at 5:20

0

You must log in to answer this question.

Browse other questions tagged .