2
$\begingroup$

The objects i make invisible in viewport i want them to automatically be invisible to render. Is there any cool way to have this option ?

$\endgroup$
  • 2
    $\begingroup$ I do not know of a cool way, but you can click the camera icon in the outliner. $\endgroup$ – rob Jun 28 '19 at 13:17
  • $\begingroup$ That i know, but when you have too many objects, you need to go through all. Was wondering if there was some option or python script $\endgroup$ – kay777 Jun 28 '19 at 13:19
  • 2
    $\begingroup$ bpy.data.objects["Cube"].hide_render = True $\endgroup$ – rob Jun 28 '19 at 13:24
  • 1
    $\begingroup$ Select every visible objects by pressing "A" then hit "W" and select "Restrict Render Unselected" $\endgroup$ – FFeller Jun 28 '19 at 14:59
  • $\begingroup$ @FFeller this doesnt seem to work on blender 2.8, nothing comes up after pressin W $\endgroup$ – kay777 Jun 30 '19 at 2:43
2
$\begingroup$

Handlers

Could set in a handler. bpy.app.handlers.depsgraph_update_[pre or post] are the v2.8x equivalent of scene update in versions prior.

Run this script once. Now every time the depsgraph updates ( a lot ) it will match the hide render attribute to the objects hide status.

import bpy

def hide(scene):
    for o in scene.objects:
        o.hide_render = o.hide_get()

    return None

# uncomment to clear all
#bpy.app.handlers.depsgraph_update_post.clear()
bpy.app.handlers.depsgraph_update_post.append(hide)
$\endgroup$
0
$\begingroup$

This code when run will hide all the selected objects from being rendered

import bpy 

selection = bpy.context.selected_objects 

for obj in selection: 
    bpy.data.objects[obj.name].hide_render = True

It also make sense if you are doing this a lot to change the functionality to toggle. This version will toggle the render visibility of all the selected objects

import bpy 

selection = bpy.context.selected_objects 

for obj in selection: 
    obj.hide_render = not obj.hide_render
$\endgroup$
  • $\begingroup$ thanks @batFINGER, updated $\endgroup$ – rob Jul 1 '19 at 11:32
  • $\begingroup$ In 2.79 version we could move the selected objects to some other layer and leave that layer hidden. Could it be a similar way to do it in 2.8? Unfortunately, I can't use the 2.8 version yet. $\endgroup$ – LeoNas Jul 1 '19 at 17:18

Your Answer

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

Not the answer you're looking for?Browse other questions tagged or ask your own question.