1
$\begingroup$

Following up from Part 1 I'm looking to see about making this persistent when (re)loading up blender 3.6.7, Much thanks to Chris for writing something that works when inside the text editor.

bl_info = {
    "name": "Active Background",
    "author": "Blender.Fun",
    "version": (0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "description": "Changes background when animation is playing.",
    "warning": "",
    "doc_url": "",
    "category": "Themes",
}

import bpy



def start(scene):
    bpy.context.preferences.themes[0].view_3d.space.gradients.high_gradient = (1.0, 0.0, 0.0)
    
def stop(scene):
    bpy.context.preferences.themes[0].view_3d.space.gradients.high_gradient = (0.2, 0.2, 0.2)
    
    
   
def register(): 
    bpy.app.handlers.animation_playback_post.append(stop)
    bpy.app.handlers.animation_playback_pre.append(start)

    
def unregister():
    bpy.app.handlers.animation_playback_post.remove(stop)
    bpy.app.handlers.animation_playback_pre.remove(start)
 
if __name__ == "__main__":
    register()
$\endgroup$

1 Answer 1

1
$\begingroup$
bl_info = {
    "name": "Active Background",
    "author": "Blender.Fun",
    "version": (0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "description": "Changes background when animation is playing.",
    "warning": "",
    "doc_url": "",
    "category": "Themes",
}

import bpy
from bpy.app.handlers import persistent

@persistent
def start(scene):
    bpy.context.preferences.themes[0].view_3d.space.gradients.high_gradient = (1.0, 0.0, 0.0)
 
@persistent   
def stop(scene):
    bpy.context.preferences.themes[0].view_3d.space.gradients.high_gradient = (0.2, 0.2, 0.2)
    
    
def register(): 
    bpy.app.handlers.animation_playback_post.append(stop)
    bpy.app.handlers.animation_playback_pre.append(start)

def unregister():
    bpy.app.handlers.animation_playback_post.remove(stop)
    bpy.app.handlers.animation_playback_pre.remove(start)
 
if __name__ == "__main__":
    register()

copy this code in your text editor, save the text with text-> save as

enter image description here

and use any name with ".py" at the end.

Then go to your add-ons preferences, press install, choose that py file.

Done.

$\endgroup$
2
  • $\begingroup$ Thanks, and enjoy the free coffee :D $\endgroup$ Commented Mar 15 at 14:01
  • $\begingroup$ thank you very much!!! $\endgroup$
    – Chris
    Commented Mar 15 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .