Jump to content

how to batch render with a set of cameras times (cartesian product) textures ?


soleil

Recommended Posts

With a python script, I'm trying to queue for render the current project with different (vray) cameras, different texture path for a given (vray) material, and different rendered image filename, and a certain setting. I could not find a way to control what I queue.

I have in a project vray cameras:

 
camNameList = ["vray Cam2 global", "vray Cam1 close tree", "vray Cam3 closer tree", "vray Cam4 angle L", "vray Cam5 angle R", "vray Cam6", "floor"] 


but I can't access to them:batch = documents.GetBatchRender()

 
batch.Open()
batch.AddFile(file, 1) # works but I have not control over 1) which camera
    # 2) which render setting 3) which filename for the rendered image

camOList = doc.SearchObject("vray Cam2 global")
print (camOList) # result: None
  
bd  = doc.GetActiveBaseDraw()
cam = bd.GetEditorCamera()
cname = bd.GetSceneCamera(doc)
print(cam.GetName()) # result: Camera
print(cname.GetName()) # result: Camera


I will use then those functions to do the cartesian product of cameras X textures and specify the render file names:

 
from os.path import isfile, join

def GetTex(path):
    return [f for f in listdir(path) if isfile(join(path, f)) and f.endswith(".JPG") and f not in doneFiles]

def FilterCams(camNameList, camTagList):
    return [c for c in camNameList for t in camTagList if t in c]
  
def GetRenderUple(renderList):
    finalUple = []
    for file, camtag in renderList:
        filetag = file.split(".")[0]
        cameraName = [c for c in camNameList if camtag in c][0]
        renderFile = filetag + "_" + camtag + ".tif"
        finalUple.append((file, cameraName, renderFile))
    return finalUple


example:

from os import listdir
from itertools import product

camNumbers = [2,1,4,5]
camTagList = ["Cam"+str(i) for i in camNumbers]

camNameList = ["vray Cam2 global", "vray Cam1 close tree", "vray Cam3 closer tree", "vray Cam4 angle L", "vray Cam5 angle R", "vray Cam6", "floor"]
# [c.GetName() for c in currentbasedocument.GetAllCameras()]
  
selectedCam = FilterCams(camNameList, camTagList)
# print(selectedCam)
  
renderList = list(product(flist, camTagList))
# print(renderList)

 

Edited by soleil
code format 3 (see edit history)
Link to comment
×
×
  • Create New...

Copyright Core 4D © 2023 Powered by Invision Community