2
$\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$
  • $\begingroup$ Have you looked at on_load handlers? blender.org/api/blender_python_api_2_75_release/… $\endgroup$ – batFINGER Sep 18 '15 at 23:54
  • $\begingroup$ 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! $\endgroup$ – Isaac Sep 19 '15 at 4:00
  • $\begingroup$ Does it have to be bpy.types.Scene what about bpy.types.WindowManager $\endgroup$ – batFINGER Sep 22 '15 at 20:03
  • $\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 Sep 24 '15 at 2:34
  • 1
    $\begingroup$ @WindUpToy This confirms my answer to both questions: blender.stackexchange.com/a/8443/2387 $\endgroup$ – Isaac Dec 31 '17 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.