使用 python 脚本,我正在尝试使用不同的 (vray) 相机、给定 (vray) 材质的不同纹理路径、不同的渲染图像文件名和特定设置来排队渲染当前项目。我找不到控制我排队的方法。
我的问题是:
如何获取当前文档中所有(vray)相机的列表?伪代码:
camNameList = [c.GetName() for c in currentbasedocument.GetAllCameras()]
如何编辑(vray)材质的纹理?
如何排队集合 {cameras} ✕ {textures} 和渲染?
我有一个项目 vray 相机:
camNameList = ["vray Cam2 global", "vray Cam1 close tree", "vray Cam3 closer tree",
"vray Cam4 angle L", "vray Cam5 angle R", "vray Cam6", "floor"]
但我没有设法访问它们:
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"
然后我将使用这些函数来做 {cameras} ✕ {textures} 的笛卡尔积并指定渲染文件名:
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
笛卡尔积没问题:
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)