0
$\begingroup$

I simply need to know how to unhide a collection after hiding it using bpy. Many questions have been answered but none seem to work with Blender 2.83.

My product has many add-ons and I need to render each one individually, for argument's sake let's say it's an ice cream and I need to show a cone but with a ball of each type of ice cream in it. The cone and each ball of ice cream is in a separate collection.

I start with disabling all from the render (a form of reset of the scene if you will), re-enable the cone and subsequently re-enable each ball for rendering, rendering it then re-disabling it and re-enabling the next ball.

I can get all collections to disable for render, re-enabling is proving elusive.

My code:

import bpy
import mathutils

# Store the current scene inside a variable
scene = bpy.context.scene

# Exlude all Collections from view layer    
coll = bpy.data.collections

for c in coll:
    c.hide_render=True

# ENABLING BY COLLECTION NAME GOES HERE
# ENABLING BY COLLECTION NAME GOES HERE
# ENABLING BY COLLECTION NAME GOES HERE
# ENABLING BY COLLECTION NAME GOES HERE
# ENABLING BY COLLECTION NAME GOES HERE

# Rendering

# set file image index
index = 0
# render settings
scene.render.image_settings.file_format = 'PNG'
bpy.data.scenes["CONFIGURATOR 800x600"].render.filepath = '/BlenderPythonTest/render_%d.png' % index
bpy.ops.render.render(write_still = 1)

I have tried bpy.data.scenes.layer_collection exclude, bpy.data.collections hide_render False and bpy.context.collection hide_render methods, but nothing works. By that I mean it renders a large black square (if I do not disable at the beginning, all renders fine).

Please help... failing that, enjoy the ice cream you're heading to the fridge for... ;-)

$\endgroup$
0
0
$\begingroup$

Ok this was my bad. I got it right first time by using:

bpy.data.collections["COMMON REAL ESTATE"].hide_render=False

BUT, I have nested collections in collections. So in this example I wanted to render objects in "COMMON REAL ESTATE", but "COMMON REAL ESTATE" is a child to another collection called "REAL ESTATE", which you also have to activate for rendering. It's not like the "Exclude from View Layer" checkbox where you can just dive in and tick the box anywhere in the chain and it'll render.

$\endgroup$

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.