2

我正在尝试通过Deadline Software将 Maya 渲染发送到渲染场。

用于手动提交作业的 Python 命令 Maya 到最后期限。

import sys
import subprocess
import maya.cmds as cmds

deadline = "C:\\Program Files\\Thinkbox\\Deadline\\bin\\deadlinecommand.exe"
maya_exe = "C:\\Program Files\\Autodesk\\Maya2015\\bin\\render.exe"

file_path = cmds.file(q=True, location=True)

command = '%s ' \
          '-SubmitCommandLineJob ' \
          '-executable "%s" ' \
          '-name "File Name" ' \
          '"%s" ' % (deadline, maya_exe, file_path)
process = subprocess.Popen(command, stdout=subprocess.PIPE)
lines_iterator = iter(process.stdout.readline, b"")
for line in lines_iterator:
    print(line)
    sys.stdout.flush()

任何将玛雅渲染添加到截止日期的python方法..?

4

2 回答 2

1

最后,我找到了将 Maya 渲染作业发送到截止日期渲染农场软件的方法。我们需要做的就是为截止日期编写 2 个作业文件。1. maya_deadline_job.job 2. maya_deadline_info.job

并将这些文件作为参数传递给deadlinecommand.exe,例如:

deadlinecommand.exe "maya_deadline_info.job"  "maya_deadline_info.job"

这是我的python代码

"""
This script will submit current file to deadline for render
"""
import os
import sys
import subprocess
import maya.cmds as cmds


def maya_deadline_job():
    """
    this function will collect scene file information and write a job file
    :return:
    """
    renderer_name = 'File'
    version = cmds.about(version=True)
    project_path = cmds.workspace(q=True, directory=True)
    width = cmds.getAttr("defaultResolution.width")
    height = cmds.getAttr("defaultResolution.height")
    output_file_path = cmds.workspace(expandName="images")
    output_file_prefix = cmds.getAttr("defaultRenderGlobals.imageFilePrefix")
    scene_file = cmds.file(q=True, location=True)
    info_txt = 'Animation=1\n' \
               'Renderer={}\n' \
               'UsingRenderLayers=0\n' \
               'RenderLayer=\n' \
               'RenderHalfFrames=0\n' \
               'LocalRendering=0\n' \
               'StrictErrorChecking=1\n' \
               'MaxProcessors=0\n' \
               'AntiAliasing=low\n' \
               'Version={}\n' \
               'Build=64bit\n' \
               'ProjectPath={}\n' \
               'ImageWidth={}\n' \
               'ImageHeight={}\n' \
               'OutputFilePath={}\n' \
               'OutputFilePrefix={}\n' \
               'Camera=\n' \
               'Camera0=\n' \
               'Camera1=RENDERShape\n' \
               'Camera2=frontShape\n' \
               'Camera3=perspShape\n' \
               'Camera4=sideShape\n' \
               'Camera5=topShape\n' \
               'SceneFile={}\n' \
               'IgnoreError211=0'.format(renderer_name
                                         version,
                                         project_path,
                                         width,
                                         height,
                                         output_file_path,
                                         output_file_prefix,
                                         scene_file)

    maya_deadline_job_file = r'{}\maya_deadline_job.job'.format(os.getenv('TEMP'))
    with open(maya_deadline_job_file, 'w') as job_file:
        job_file.write(info_txt)
    return maya_deadline_job_file


def maya_deadline_info():
    """
    this function will collect maya deadline information and write a job file
    :return:
    """
    info_txt = 'Plugin=MayaBatch\n' \
               'Name=MY_FILE_NAME\n' \
               'Comment=Render Launch by Python\n' \
               'Pool=none\n' \
               'MachineLimit=0\n' \
               'Priority=50\n' \
               'OnJobComplete=Nothing\n' \
               'TaskTimeoutMinutes=0\n' \
               'MinRenderTimeMinutes=0\n' \
               'ConcurrentTasks=1\n' \
               'Department=\n' \
               'Group=none\n' \
               'LimitGroups=\n' \
               'JobDependencies=\n' \
               'InitialStatus=Suspended\n' \
               'OutputFilename0=C:/Users/raijv/Documents/maya/projects/default/images/masterLayer_2.iff.????\n' \
               'Frames=1-10\n' \
               'ChunkSize=1'

    maya_deadline_info_file = r'{}\maya_deadline_info.job'.format(os.getenv('TEMP'))
    with open(maya_deadline_info_file, 'w') as job_file:
        job_file.write(info_txt)
    return maya_deadline_info_file


def submit_to_deadline():
    """
    this function will send current scene to deadline for rendering
    :return:
    """
    deadline_cmd = r"C:\Program Files\Thinkbox\Deadline\bin\deadlinecommand.exe"
    job_file = maya_deadline_job()
    info_file = maya_deadline_info()
    command = '{deadline_cmd} "{job_file}" "{info_file}"'.format(**vars())
    process = subprocess.Popen(command, stdout=subprocess.PIPE)
    lines_iterator = iter(process.stdout.readline, b"")
    #  Lets print the output log to see the Error / Success 
    for line in lines_iterator:
        print(line)
        sys.stdout.flush()

submit_to_deadline()

编辑信息 -

不要在 renderer_name 变量中使用 cmds.getAttr("defaultRenderGlobals.currentRenderer" 。使用将层覆盖渲染器的文件。

于 2016-05-25T04:47:36.183 回答
1

我曾为玛雅内部的核工作编写了一个出口商。它也应该与 Maya 一起使用(即使我不明白你没有使用截止日期脚本 - 请注意,nuke 的截止日期在 .py 中有一个提交者):

我正在使用 xml 编辑两个部分文件: nuke_submit_info.job nuke_plugin_info.job 为 maya 找到相同的文件,它应该可以解决问题

然后用'deadlinecommand'提交它们

def sumbit2deadline():
    FileName = "nuke_submit_info"
    JobInfo = PathSaveFiles + FileName + ".job"
    FileName = "nuke_plugin_info"
    JobPlugIn = PathSaveFiles + FileName + ".job"
    FileName = "NukeTemplate"
    JobFile = PathSaveFiles + FileName + ".nk"
    command = "deadlinecommand" + " " + JobInfo + " " + JobPlugIn + " " + JobFile
    subprocess.Popen(command)
于 2016-05-24T12:28:41.957 回答