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.
My question is:
how get the list of all (vray) cameras in the current document ? pseudo code:
camNameList = [c.GetName() for c in currentbasedocument.GetAllCameras()]
how to edit the texture of a (vray) material ?
how to queue the set {cameras} ✕ {textures} and render ?
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 did not manage to 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" but it is not in camNameList
print(cname.GetName()) # result: "Camera"
I will use then those functions to do the cartesian product of {cameras} ✕ {textures} and specify the render file names:
from os.path import isfile, join
doneFiles = ["im1.JPG", "im2.JPG"]
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
no problem with the cartesian product:
from os import listdir
from itertools import product
camNumbers = [2,1,4,5]
camTagList = ["Cam"+str(i) for i in camNumbers]
selectedCam = FilterCams(camNameList, camTagList)
# print(selectedCam)
renderList = list(product(flist, camTagList))
# print(renderList)