Script for hiding from view all that hidden from render?

Hi, I wonder if there is a script that could automatically hide from view all the objects that are hidden from render?

Like this?

import bpy

all_objects = bpy.context.scene.objects

for obj in all_objects:
    if obj.hide_render:
        obj.hide_viewport = True
        obj.hide_viewport = False

Thanks dan, That looks very simple, i will give it a try. :+1:

or in one line, (more readable imo)

for obj in
    obj.hide_viewport = obj.hide_render
1 Like

Sorry “Gorgious” This one didn’t work for me?

Maybe should have been…?

1 Like