azure-batch-maya/azure_batch_maya/modules/maya_software.py

93 строки
3.2 KiB
Python
Исходник Постоянная ссылка Обычный вид История

2017-05-23 19:13:11 +03:00
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
2015-05-26 04:23:47 +03:00
2017-10-05 23:27:12 +03:00
from __future__ import unicode_literals
2015-05-26 04:23:47 +03:00
import os
import sys
import gzip
2017-04-26 00:27:21 +03:00
import json
from maya import cmds, mel
2015-05-26 04:23:47 +03:00
2017-04-26 00:27:21 +03:00
from default import AzureBatchRenderJob, AzureBatchRenderAssets
2015-05-26 04:23:47 +03:00
2017-10-05 23:27:12 +03:00
try:
str = unicode
except NameError:
pass
2015-05-26 04:23:47 +03:00
2017-04-26 00:27:21 +03:00
class AzureBatchMayaJob(AzureBatchRenderJob):
2015-05-26 04:23:47 +03:00
2017-05-23 00:56:45 +03:00
render_engine = "mayaSoftware"
2015-05-26 04:23:47 +03:00
def __init__(self):
2017-05-23 00:56:45 +03:00
self._renderer = "sw"
2015-05-26 04:23:47 +03:00
self.label = "Maya Software"
def settings(self):
if self.scene_name == "":
job_name = "Untitled"
else:
job_name = str(os.path.splitext(os.path.basename(self.scene_name))[0])
2017-04-26 00:27:21 +03:00
file_prefix = mel.eval("getAttr defaultRenderGlobals.imageFilePrefix")
if file_prefix:
file_prefix = os.path.split(file_prefix)[1]
else:
file_prefix = "<Scene>.<Camera>.<RenderLayer>"
2015-05-26 04:23:47 +03:00
self.job_name = self.display_string("Job Name: ", job_name)
2017-04-26 00:27:21 +03:00
self.output_name = self.display_string("Output Prefix: ", file_prefix)
2015-05-26 04:23:47 +03:00
self.start = self.display_int("Start frame: ", self.start_frame, edit=True)
self.end = self.display_int("End frame: ", self.end_frame, edit=True)
self.step = self.display_int("Frame step: ", self.frame_step, edit=True)
def get_title(self):
return str(cmds.textField(self.job_name, query=True, text=True))
def render_enabled(self):
return True
def get_jobdata(self):
2017-05-23 00:56:45 +03:00
if self.scene_name == '':
2015-05-26 04:23:47 +03:00
raise ValueError("Current Maya scene has not been saved to disk.")
2017-05-23 00:56:45 +03:00
2017-04-26 00:27:21 +03:00
pending_changes = cmds.file(query=True, modified=True)
if not pending_changes:
2017-05-23 00:04:11 +03:00
return self.scene_name, [self.scene_name]
options = {
'save': "Save and continue",
'nosave': "Continue without saving",
'cancel': "Cancel"
}
2017-05-23 00:56:45 +03:00
answer = cmds.confirmDialog(title="Unsaved Changes",
message="There are unsaved changes. Continue?",
2017-05-23 00:04:11 +03:00
button=options.values(),
defaultButton=options['save'],
cancelButton=options['cancel'],
dismissString=options['cancel'])
if answer == options['cancel']:
2017-05-23 19:13:11 +03:00
raise Exception("Submission cancelled")
2017-05-23 00:04:11 +03:00
if answer == options['save']:
2017-04-26 00:27:21 +03:00
cmds.SaveScene()
2017-05-23 00:04:11 +03:00
return self.scene_name, [self.scene_name]
2015-05-26 04:23:47 +03:00
def get_params(self):
params = {}
2017-05-23 00:56:45 +03:00
params["frameStart"] = cmds.intField(self.start, query=True, value=True)
params["frameEnd"] = cmds.intField(self.end, query=True, value=True)
params["frameStep"] = cmds.intField(self.step, query=True, value=True)
params["renderer"] = self._renderer
2015-05-26 04:23:47 +03:00
return params
2017-04-26 00:27:21 +03:00
class MayaRenderAssets(AzureBatchRenderAssets):
assets = []
2015-05-26 04:23:47 +03:00
render_engine = "mayaSoftware"
def renderer_assets(self):
return self.assets