Keep the light on while changing collections in rendered mode

Hi everyone,

The collection system is a blessing, and everything is logical; but as I switch between my main collections through numbers (1,2,3,…) in rendered mode, or when I switch to local view (/), or hide the rest of the scene (Shift+H), I always end up with this light-off effect that forces me to switch the light back on.

I understand why it is difficult to avoid in local view and Shift+H view, although I’d really like to have an option therefore; and I chose to put the lights in the main collection to keep them on when I switch between the main layers.

As the rendered view becomes available as a working environment in Eevee; finding a way to extract the lights from the visibility matters would be very handy.

My eternal gratitude to the problem solver, if born he/she is.

It should be possible to make addon that replaces default behaviour of Shift+H shortcut and 1,2,3

Just for test, forcing all lights on by timer:

import bpy

def force_lights_on():
    for obj in bpy.data.objects:
        if obj.type=='LIGHT':
            if obj.hide_get() == True: # hide_set is heavy, run it only when needed.
                obj.hide_set(False)
    return 1 # every 1 second
    
bpy.app.timers.register(force_lights_on)

Generally really bad idea to have timer running all the time, but atleast it seem to work, and does not use much cpu.

Hi Cmzy,

Thank you for your answer!

The 1/2/3 issue has been solved by placing the lights in the main collection.
I tried to run the script before and after running the timeline, and before and after isolating some objects with Shift+H but did not achieve to keep the lights on.

It sounds interesting though-I was thinking to add the heartbeat and the breathing movements to the atlas on which I work (https://www.z-anatomy.com/); could you post an exemple (https://pasteall.org/blend/) or explain me how you set it up?

Hello!

That is simple test of concept. Should work when copied to Blender text editor and hit Run Script button.

For proper addon, there should be atleast have some way to stop timer.

Perhaps heartbeat could be done with normal Blender animation or geometry nodes?
You could set timeline to one heartbeat length so it loops in viewport.

Sorry, I realized my earlier code didn’t indeed work. That’s because bpy.data.lights.keys() is not really list of light objects.

I changed the earlier answer, should work now.

Btw, nice project!