# Always render the visible objects

I am using Blender for some scientific-related visualization. As such I guess my needs are much more modest than those of the average animator, and the decoupling of the visibility and renderability of objects (i.e., the fact I can set some object to rendered although it is not visible in preview) only causes problems for me, when I change what is visible but forget to also set it to be rendered, only to come back 15 minutes later and see that I had rendered the wrong scene. Is there some way to "couple" visibility and renderability, i.e. only whatever is set as visible is also set as renderable?

You could also do this with Python!

To do so you could run the following code, manually, before rendering:

import bpy

for obj in bpy.data.objects:
obj.hide_render = obj.hide


A better solution would be to somehow run the code automagically before rendering, which can be done as follows:

import bpy

def unhide(self):
for obj in bpy.data.objects:
obj.hide_render = obj.hide

bpy.app.handlers.render_pre.append(unhide)


To make the script run every time you open up the blend file, name your text block with a .py extension and check Register.

Note that you must run the script once;

• I tried so hard to do this... D: – GiantCowFilms Jan 13 '15 at 23:52
• @GiantCowFilms I noticed in chat :) it really is simple, though – someonewithpc Jan 14 '15 at 7:30
• I kept on trying to do it using the same steps as my answer :/. I don't really no how to code python, or anything about whats in bpy.... – GiantCowFilms Jan 14 '15 at 15:54
• @GiantCowFilms Python is really simple; and as far as knowing the API, there's always the api docs and Google it self :D – someonewithpc Jan 14 '15 at 17:14
• @someonewithpc - give the textblock a .py name and enable register - it will run on file open. – sambler Jan 15 '15 at 4:01

Here is a simple process to do before rendering:

1. Deselect all your object A
2. Hit Alt-H to unhide all the objects
3. Without changing the selection, hit Ctrl-H, your objects will be hidden
4. Hit H to hide them again.

For better scene organization I suggest you to use the new layer management addon. With this you can simply disable a layer if you don't want to render it.