5
$\begingroup$

I'd like to render all objects on the blend file and render them one by one seperately. I'd like it to:

  • Render the object on selected collection
  • Save it with the obj name as png to folder (if folder name can be the collection name, that'll be pretty life saver)
  • Render the next obj

And if i can keep the shadows, that'll be bonus!

$\endgroup$
11
$\begingroup$

You'd have to use python for this. Make sure the collection that you'd like to render is selected/active in the Outliner and run the following script:

import bpy
import os.path

C = bpy.context
scn = C.scene
output_path = scn.render.filepath
exclude_type = ('LIGHT', 'CAMERA', 'ARMATURE', 'LIGHT_PROBE', 'SPEAKER')

# Disable all relevant objects in renders
for ob in C.collection.objects:
    if ob.type not in exclude_type:
        ob.hide_render = True

for ob in C.collection.objects:
    if ob.type not in exclude_type:
        # Enable the object for rendering
        ob.hide_render = False
        # Assemble the path (.jpg is a placeholder)
        scn.render.filepath = os.path.join(output_path, "{}.jpg".format(ob.name))
        # Call the render operator
        bpy.ops.render.render(write_still=True)
        # Disable the object for rendering
        ob.hide_render = True

# Reset the output path
bpy.context.scene.render.filepath = output_path
# Reset hide_render state
for ob in C.collection.objects:
    if ob.type not in exclude_type:
        ob.hide_render = False

Render output of the default scene, added a Sphere and a Cylinder to the default Collection:

/tmp/
├── Cube.png
├── Sphere.png
├── Cylinder.png

To get the shadow just add a Plane to the Scene Collection, make it a Shadow Catcher (Object Properties > Visibility) and enable Transparent (Render Properties > Film):

enter image description here

Render output of the shadow catcher scene (Cube.png, Cylinder.png, Sphere.png):

enter image description here

If you'd like to have a subfolder with the actual name of the collection, just add it to the regular output path e.g. /tmp/Collection/.

Related:

$\endgroup$
1
  • 1
    $\begingroup$ Dude thank you, this literally saved me thousands of minutes! $\endgroup$ Oct 25 at 13:21

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.