1
$\begingroup$

I am working on generative art and I need to set up my renders to render only 1 object per collection (a different one each frame) without having to do that manually. I am not very familiar with geometry nodes yet so I am not sure if it is possible this way. Another possibility that crossed my mind is an addon, but I haven't found anything useful.

Do you guys have any idea?

$\endgroup$
1
  • $\begingroup$ It's not really a thing for geometry nodes, and as far as I know, there are no existing add-ons, but there have been several questions here about it. You might want to search for similar questions. $\endgroup$ Commented Dec 27, 2021 at 18:16

1 Answer 1

1
$\begingroup$

You question is not a complete specification of what you want or not 100 percent clear to me. So I'll do an example for you to work with. I'll assume you want a render of one object from each of several Collections per render file, and that you want all combinations. I'll try to give pointers to a variation where you select an object at random from a Collection.

I would use a python script that first disables all objects from rendering and then varies what objects are render-enabled.

This may not be the simplest script, but is a variation on an existing script I have:

import bpy
import random

# constants
nCollections = len(bpy.data.collections)
frameCnt=0
filepathBase="//render/frame"
startFrameIdx=0
frameRenderCnt=999999

# set up a function to recurse through each collection
def renderCollection( collectionIdx, frameIdx: int, frameName ) -> int:
    if collectionIdx == (len(bpy.data.collections)):  # frame ready to render
        bpy.context.scene.render.filepath = frameName
        print('rendering', frameName)
        bpy.ops.render.render( write_still=True )
        frameIdx += 1         
    else:
        # if you only want one random from each collection, replace 'for' loop with
        #obj = random.choice(bpy.data.collections[collectionIdx].objects)
        for obj in bpy.data.collections[collectionIdx].objects:
            obj.hide_render = False  # allow object to render
            tempFrameName = frameName + "_" + obj.name
            frameIdx:int = renderCollection( collectionIdx + 1, frameIdx, tempFrameName )  # march onward until rendered
            obj.hide_render = True  # prevent object render
            if ( frameIdx >= frameRenderCnt):
                return;
    return frameIdx


# INITIALIZE: prevent all objects from rendering
for coll in bpy.data.collections:
    for obj in coll.objects:
        obj.hide_render = True

# for each collection
total = renderCollection( 0, 0, filepathBase )
print( total, ' frames rendered' )

And a proof of concept: (I'm getting the 'All uploaded files must be in the blend file format' 3.0 bug again from the upload site so...) here a link to my Public DropBox example blend file.

$\endgroup$
4
  • $\begingroup$ Thank you, James, that's exactly what I want! However I have no coding experience so I can't adjust it to my specific needs. Could you PLEASE adjust it so I can render only certain range of frames at a time? I have a lot of objects in my collections and total number of renders would be over 10000, so running this script would freeze my PC forever. $\endgroup$ Commented Dec 27, 2021 at 21:26
  • 1
    $\begingroup$ @VáclavMusil -- demanding customer LOL! Okay try what I updated in the script above. For each run just change the startFrameIdx to the next group and frameRenderCnt to some more reasonnable number of frames to produce for each time. So if frameRenderCnt=10, then run 1 startFrameIdx=0 , then run 2 startFrameIdx=10, etc. $\endgroup$
    – james_t
    Commented Dec 27, 2021 at 22:15
  • $\begingroup$ Thank you so much! I will save so much time because of you. Words cannot describe how thankful I am. <3 $\endgroup$ Commented Dec 27, 2021 at 23:32
  • $\begingroup$ @VáclavMusil -- I work for credits: if you get the chance, click on the check mark on the top of my answer, so I will accumulate expert points, and an up-arrow if you haven't already. thanks. $\endgroup$
    – james_t
    Commented Dec 29, 2021 at 18:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .