3

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?

Isaac
  • 596
  • 1
  • 5
  • 18
  • Have you looked at on_load handlers? http://www.blender.org/api/blender_python_api_2_75_release/bpy.app.handlers.html – batFINGER Sep 18 '15 at 23:54
  • The load handlers do not give you access to the scene, however the scene update handlers do. Not sure if it's the best solution but it defiantly gets the job done (it doesn't change how the property is accessed, which is really nice). Thanks for the info! – Isaac Sep 19 '15 at 04:00
  • 1
    Does it have to be bpy.types.Scene what about bpy.types.WindowManager – batFINGER Sep 22 '15 at 20:03
  • 1
    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. – Isaac Sep 24 '15 at 02:34
  • I wonder if the 'SKIP_SAVE' argument passed to the bpy.props types has anything to do with this? The documentation leaves a lot to be desired. https://docs.blender.org/api/blender_python_api_2_77_0/bpy.props.html – 371273 Dec 31 '17 at 03:44
  • Can you elaborate on why you mention the window manager? Is it documented somewhere that properties on the window manager are not saved? – 371273 Dec 31 '17 at 03:46
  • 1
    @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. – Isaac Dec 31 '17 at 05:17
  • 2
    @WindUpToy This confirms my answer to both questions: https://blender.stackexchange.com/a/8443/2387 – Isaac Dec 31 '17 at 05:20

0 Answers0