Skip to content

Instantly share code, notes, and snippets.

@WesleyE
Created June 30, 2015 15:02
Show Gist options
  • Save WesleyE/f40897b1abe92b11cdcf to your computer and use it in GitHub Desktop.
Save WesleyE/f40897b1abe92b11cdcf to your computer and use it in GitHub Desktop.
This script allows you to quickly create a batch render from multiple camera's and multiple ranges in Maya.
# -*- coding: utf-8 -*-
"""
The MIT License (MIT)
Copyright (c) 2014 Wesley Elfring
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."""
from PySide import QtCore, QtGui
import pymel.core as pm
import subprocess
#UI code from designer
class BR_Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(672, 503)
self.centralWidget = QtGui.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.gridLayout_2 = QtGui.QGridLayout(self.centralWidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.label = QtGui.QLabel(self.centralWidget)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.tabWidget = QtGui.QTabWidget(self.centralWidget)
self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded)
self.tabWidget.setObjectName("tabWidget")
self.tab_cameras = QtGui.QWidget()
self.tab_cameras.setObjectName("tab_cameras")
self.gridLayout_5 = QtGui.QGridLayout(self.tab_cameras)
self.gridLayout_5.setObjectName("gridLayout_5")
self.lw_camera_available = QtGui.QListWidget(self.tab_cameras)
self.lw_camera_available.setObjectName("lw_camera_available")
self.gridLayout_5.addWidget(self.lw_camera_available, 0, 0, 1, 1)
self.btn_deselect = QtGui.QPushButton(self.tab_cameras)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(80)
sizePolicy.setHeightForWidth(self.btn_deselect.sizePolicy().hasHeightForWidth())
self.btn_deselect.setSizePolicy(sizePolicy)
self.btn_deselect.setMaximumSize(QtCore.QSize(25, 16777215))
self.btn_deselect.setObjectName("btn_deselect")
self.gridLayout_5.addWidget(self.btn_deselect, 0, 1, 1, 1)
self.btn_select = QtGui.QPushButton(self.tab_cameras)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.btn_select.sizePolicy().hasHeightForWidth())
self.btn_select.setSizePolicy(sizePolicy)
self.btn_select.setMaximumSize(QtCore.QSize(25, 16777215))
self.btn_select.setObjectName("btn_select")
self.gridLayout_5.addWidget(self.btn_select, 0, 2, 1, 1)
self.lw_camera_selected = QtGui.QListWidget(self.tab_cameras)
self.lw_camera_selected.setObjectName("lw_camera_selected")
self.gridLayout_5.addWidget(self.lw_camera_selected, 0, 3, 1, 1)
self.tabWidget.addTab(self.tab_cameras, "")
self.tab_ranges = QtGui.QWidget()
self.tab_ranges.setObjectName("tab_ranges")
self.gridLayout_6 = QtGui.QGridLayout(self.tab_ranges)
self.gridLayout_6.setObjectName("gridLayout_6")
self.tableWidget = QtGui.QTableWidget(self.tab_ranges)
self.tableWidget.setAlternatingRowColors(True)
self.tableWidget.setShowGrid(True)
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(4)
item = QtGui.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(0, item)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(3, item)
self.tableWidget.horizontalHeader().setVisible(True)
self.tableWidget.horizontalHeader().setCascadingSectionResizes(False)
self.tableWidget.verticalHeader().setVisible(False)
self.gridLayout_6.addWidget(self.tableWidget, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_ranges, "")
self.tab_settings = QtGui.QWidget()
self.tab_settings.setObjectName("tab_settings")
self.gridLayout_4 = QtGui.QGridLayout(self.tab_settings)
self.gridLayout_4.setObjectName("gridLayout_4")
self.formLayout = QtGui.QFormLayout()
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.lbl_heading = QtGui.QLabel(self.tab_settings)
self.lbl_heading.setObjectName("lbl_heading")
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.lbl_heading)
self.lbl_path = QtGui.QLabel(self.tab_settings)
self.lbl_path.setObjectName("lbl_path")
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.lbl_path)
self.le_path = QtGui.QLineEdit(self.tab_settings)
self.le_path.setObjectName("le_path")
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.le_path)
self.btn_browse = QtGui.QPushButton(self.tab_settings)
self.btn_browse.setObjectName("btn_browse")
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.btn_browse)
self.lbl_pathhelp = QtGui.QLabel(self.tab_settings)
self.lbl_pathhelp.setAlignment(QtCore.Qt.AlignCenter)
self.lbl_pathhelp.setObjectName("lbl_pathhelp")
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.lbl_pathhelp)
self.lbl_filename = QtGui.QLabel(self.tab_settings)
self.lbl_filename.setObjectName("lbl_filename")
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.lbl_filename)
self.le_filename = QtGui.QLineEdit(self.tab_settings)
self.le_filename.setObjectName("le_filename")
self.formLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.le_filename)
self.lbl_filenamehelp = QtGui.QLabel(self.tab_settings)
self.lbl_filenamehelp.setObjectName("lbl_filenamehelp")
self.formLayout.setWidget(5, QtGui.QFormLayout.FieldRole, self.lbl_filenamehelp)
self.lbl_padding = QtGui.QLabel(self.tab_settings)
self.lbl_padding.setObjectName("lbl_padding")
self.formLayout.setWidget(6, QtGui.QFormLayout.LabelRole, self.lbl_padding)
self.sb_padding = QtGui.QSpinBox(self.tab_settings)
self.sb_padding.setProperty("value", 4)
self.sb_padding.setObjectName("sb_padding")
self.formLayout.setWidget(6, QtGui.QFormLayout.FieldRole, self.sb_padding)
self.lbl_playblast = QtGui.QLabel(self.tab_settings)
self.lbl_playblast.setObjectName("lbl_playblast")
self.formLayout.setWidget(8, QtGui.QFormLayout.LabelRole, self.lbl_playblast)
self.checkBox = QtGui.QCheckBox(self.tab_settings)
self.checkBox.setText("")
self.checkBox.setObjectName("checkBox")
self.formLayout.setWidget(8, QtGui.QFormLayout.FieldRole, self.checkBox)
self.lbl_playblasthelp = QtGui.QLabel(self.tab_settings)
self.lbl_playblasthelp.setObjectName("lbl_playblasthelp")
self.formLayout.setWidget(9, QtGui.QFormLayout.FieldRole, self.lbl_playblasthelp)
self.lbl_format = QtGui.QLabel(self.tab_settings)
self.lbl_format.setObjectName("lbl_format")
self.formLayout.setWidget(10, QtGui.QFormLayout.LabelRole, self.lbl_format)
self.cb_format = QtGui.QComboBox(self.tab_settings)
self.cb_format.setObjectName("cb_format")
self.cb_format.addItem("Photo - JPEG")
self.cb_format.addItem("Animation")
self.cb_format.addItem("H.264")
self.formLayout.setWidget(10, QtGui.QFormLayout.FieldRole, self.cb_format)
self.btn_go = QtGui.QPushButton(self.tab_settings)
self.btn_go.setObjectName("btn_go")
self.formLayout.setWidget(11, QtGui.QFormLayout.FieldRole, self.btn_go)
self.gridLayout_4.addLayout(self.formLayout, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_settings, "")
self.tab_help = QtGui.QWidget()
self.tab_help.setObjectName("tab_help")
self.gridLayout_3 = QtGui.QGridLayout(self.tab_help)
self.gridLayout_3.setObjectName("gridLayout_3")
self.tb_help = QtGui.QTextBrowser(self.tab_help)
self.tb_help.setObjectName("tb_help")
self.gridLayout_3.addWidget(self.tb_help, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_help, "")
self.gridLayout.addWidget(self.tabWidget, 1, 0, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralWidget)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle("Batch Renderer")
self.label.setText("Animatic Batch Renderer\nWesley Elfring - scripts.wesleyelfring.nl")
self.btn_go.setText("Render!")
self.btn_deselect.setText("<<")
self.btn_select.setText(">>")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_cameras), "Cameras")
self.tableWidget.horizontalHeaderItem(0).setText("Camera")
self.tableWidget.horizontalHeaderItem(1).setText("From Range")
self.tableWidget.horizontalHeaderItem(2).setText("To Range")
self.tableWidget.horizontalHeaderItem(3).setText("Enabled")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_ranges), "Ranges")
self.lbl_heading.setText("Select Render Options")
self.lbl_path.setText("Path to save files to:")
self.btn_browse.setText("Browse")
self.lbl_pathhelp.setText("Leave empty to render in project/images/cameraname")
self.lbl_filename.setText("File name:")
self.le_filename.setText("##SCENE##_##CAMERANAME##")
self.lbl_filenamehelp.setText("Insert ##SCENE## or ##CAMERANAME## to replace them at render time.\nMake sure you've set the right 'Frame/Animation ext' in your render globals.")
self.lbl_padding.setText("Frame padding:")
self.lbl_playblast.setText("Use Playblast instead of render:")
self.lbl_playblasthelp.setText("Using the playblast option renders the cameras from the viewport.\n"
"It uses the settings of the currently active viewport.\n"
"Leaving this option off renders the camera\'s wth the global render settings.")
self.lbl_format.setText("Format to use for playblast: ")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_settings), "Settings && Render")
self.tb_help.setHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">1 - How does this work?</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">We needed something relatively simple to render multiple cameras with different frameranges.</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">With this script, you can select camera\'s, their ranges and render them as a playblast or as a real render using the current global render settings.</p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">2 - My frame ranges do not save!</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This one is simple, it searches for the camera to attach a attribute on (Check the transform -&gt; Extra Attributes).</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">If the camera name is malformed, it cannot find the transform and will fail.</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Make sure that if your camera transform is named \'Rendercam\', your camera node is called \'RendercamShape\'...</p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">3 - What settings does the playblast option use?</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">It renders to a 1920x1080 .mov with 100% quality. This option crashed a lot on our machines. Use it if it works for you...</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">You can set this around line 441 in this script.</p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">4 - Questions, bugs?</span></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Send a mail to scripts@wesleyelfring.nl</p></body></html>")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_help), "Help")
class BR_Main(QtGui.QMainWindow):
def __init__(self, *args, **kwargs):
super(BR_Main, self).__init__(*args, **kwargs)
#Setup UI
self.ui = BR_Ui_MainWindow()
self.ui.setupUi(self)
#Make the close button work
self.setAttribute( QtCore.Qt.WA_DeleteOnClose )
#Put all camera's in the list
cameras = pm.ls( cameras=True )
for cam in cameras:
if cam.hasAttr('br_enabled') and cam.getAttr('br_enabled') == 1:
self.createNewCamera(str(cam), True)
self.createTableRow(str(cam), cam.getAttr('br_range_from'), cam.getAttr('br_range_to'), cam.getAttr('br_enabled'))
else:
self.createNewCamera(str(cam), False)
self.create_connections()
self.objectCreated = cmds.scriptJob(parent='MayaWindow',
event=['DagObjectCreated', self.updateCameraList])
def create_connections(self):
self.ui.btn_browse.clicked.connect(self.selectRenderDestination)
self.ui.btn_select.clicked.connect(self.addCameraToSelection)
self.ui.btn_go.clicked.connect(self.render)
self.ui.btn_deselect.clicked.connect(self.removeCameraFromSelection)
self.ui.tableWidget.cellChanged.connect(self.tableCellChanged)
self.ui.tableWidget.cellClicked.connect(self.tableCellClicked)
pass
def createNewCamera(self, cameraName, enabled):
if enabled:
li = QtGui.QListWidgetItem(self.ui.lw_camera_selected)
else:
li = QtGui.QListWidgetItem(self.ui.lw_camera_available)
li.setText(cameraName)
def createTableRow(self, cameraName, rangeFrom, rangeTo, enabled):
newItemIndex = self.ui.tableWidget.rowCount()
self.ui.tableWidget.setRowCount(newItemIndex+1)
#Camera name
item = QtGui.QTableWidgetItem()
item.setFlags(QtCore.Qt.NoItemFlags)
item.setText(cameraName)
self.ui.tableWidget.setItem(newItemIndex, 0, item)
#Range from
item = QtGui.QTableWidgetItem()
item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsEnabled)
item.setText(str(rangeFrom))
self.ui.tableWidget.setItem(newItemIndex, 1, item)
#Range to
item = QtGui.QTableWidgetItem()
item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEditable|QtCore.Qt.ItemIsEnabled)
item.setText(str(rangeTo))
self.ui.tableWidget.setItem(newItemIndex, 2, item)
#Select
item = QtGui.QTableWidgetItem()
item.setFlags(QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled)
if enabled:
item.setCheckState(QtCore.Qt.Checked)
self.ui.tableWidget.setItem(newItemIndex, 3, item)
#Events
def selectRenderDestination(self):
directory = QtGui.QFileDialog.getExistingDirectory()
self.ui.le_path.setText(directory)
def addCameraToSelection(self):
item = self.ui.lw_camera_available.takeItem(self.ui.lw_camera_available.currentRow())
self.ui.lw_camera_selected.addItem(item)
#Find camera
camera = pm.ls( item.text(), cameras=True)[0]
self.addCameraAttributes(camera)
#Add camera to table
camera.setAttr('br_enabled', 1)
self.createTableRow(item.text(), camera.getAttr('br_range_from'), camera.getAttr('br_range_to'), camera.getAttr('br_enabled'))
def removeCameraFromSelection(self):
item = self.ui.lw_camera_selected.takeItem(self.ui.lw_camera_selected.currentRow())
self.ui.lw_camera_available.addItem(item)
#Find camera and disable it
camera = pm.ls( item.text(), cameras=True)[0]
camera.setAttr('br_enabled', 0)
#Get table item and remove it
tableItem = self.ui.tableWidget.findItems(item.text(), QtCore.Qt.MatchExactly)
self.ui.tableWidget.removeRow(tableItem[0].row())
def tableCellChanged(self, row, column):
#Fix this event triggering when building the row
if self.ui.tableWidget.item(row, 1) is None or self.ui.tableWidget.item(row, 2) is None or self.ui.tableWidget.item(row, 3) is None:
return
#Get camera
camera = pm.ls(self.ui.tableWidget.item(row, 0).text(), cameras=True)[0]
#Change attributes
rangeFrom = float(self.ui.tableWidget.item(row, 1).text())
rangeTo = float(self.ui.tableWidget.item(row, 2).text())
camera.setAttr('br_range_from', rangeFrom)
camera.setAttr('br_range_to', rangeTo)
def tableCellClicked(self, row, column):
#Handle the check click
if not column == 3:
return
camera = pm.ls(self.ui.tableWidget.item(row, 0).text(), cameras=True)[0]
if self.ui.tableWidget.item(row, 3).checkState():
camera.setAttr('br_enabled', 1)
else:
camera.setAttr('br_enabled', 0)
"""Adds camera attributes if they do not exist"""
def addCameraAttributes(self, camera):
if not camera.hasAttr('br_range'):
camera.addAttr('br_range', attributeType='double2')
camera.addAttr('br_range_from', attributeType='double', parent='br_range' )
camera.addAttr('br_range_to', attributeType='double', parent='br_range' )
camera.addAttr('br_enabled', attributeType='short')
camera.setAttr('br_range_from', 1)
camera.setAttr('br_range_to', 10)
camera.setAttr('br_enabled', 1)
"""Check if camera's are in the list, otherwise add them"""
def updateCameraList(self):
cameras = pm.ls( cameras=True )
for cam in cameras:
#Skip if it is already in one of these lists
if not self.ui.lw_camera_selected.findItems(str(cam), QtCore.Qt.MatchExactly) or not self.ui.lw_camera_available.findItems(str(cam), QtCore.Qt.MatchExactly):
continue
if cam.hasAttr('br_enabled') and cam.getAttr('br_enabled') == 1:
self.createNewCamera(str(cam), True)
self.createTableRow(str(cam), cam.getAttr('br_range_from'), cam.getAttr('br_range_to'), cam.getAttr('br_enabled'))
else:
self.createNewCamera(str(cam), False)
"""Actual render function"""
def render(self):
confirm = pm.confirmDialog(title='Confirm', message='Are you ready to render?', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
if confirm == "No":
return
#Let's get the config values
framePadding = self.ui.sb_padding.value()
renderPath = self.ui.le_path.text()
fileName = self.ui.le_filename.text()
playblast = self.ui.checkBox.checkState()
playblastFormat = self.ui.cb_format.currentText()
pathSeperator = os.path.normcase('/')
projectDir = pm.system.Workspace.getcwd()
mayaDir = os.path.join(os.path.split(sys.executable)[0], 'maya.exe')
mayaInstallDir = os.path.dirname(os.path.realpath(mayaDir))
sceneFileDir = cmds.file( query=True, list=True )[0]
sceneFilename = os.path.basename(os.path.normpath(sceneFileDir))
sceneFilename = sceneFilename.rsplit( ".", 1 )[0]
parsedRenderFileName = fileName.replace('##SCENE##', sceneFilename)
#Loop over camera's and get render them
cameras = pm.ls( cameras=True )
for cam in cameras:
if not cam.hasAttr('br_enabled') or not cam.getAttr('br_enabled'):
continue
print("Rendering camera: " + str(cam))
parsedRenderFileName = parsedRenderFileName.replace('##CAMERANAME##', str(cam))
#Build render execute string
executeString = "\"" + mayaInstallDir + os.sep + "Render\""
executeString = executeString + " -proj " + " \"" + projectDir + "\""
executeString = executeString + " -r \"file\""
executeString = executeString + " -cam \"" + str(cam) + "\""
executeString = executeString + " -im \"" + '{0}'.format(parsedRenderFileName) + "\""
renderDirectory = ''
if renderPath == '':
renderDirectory = projectDir + "/images/"+sceneFilename+"/" + str(cam) + "/"
else:
renderDirectory = '{0}'.format(renderPath) + "/"+sceneFilename+"/" + str(cam) + "/"
executeString = executeString + " -rd \"" + renderDirectory + "\""
executeString = executeString + " -pad " + '{0}'.format(framePadding)
executeString = executeString + " -s " + '{0}'.format(int(cam.getAttr('br_range_from')))
executeString = executeString + " -e "+ '{0}'.format(int(cam.getAttr('br_range_to')))
executeString = executeString + " \"" + sceneFileDir + "\""
if not playblast:
#Batchrender
subprocess.call(executeString)
print(executeString)
else:
#Playblast
mel.eval( 'lookThroughModelPanel ' + str(cam) + ' modelPanel4;')
camRange = range(int(cam.getAttr('br_range_from')), int(cam.getAttr('br_range_to'))+1) #range is non inclusive
playblastFileName = projectDir + "/images/" + parsedRenderFileName + ".mov"
#Acceptatble formats for the playblast function
pm.playblast( frame=camRange, forceOverwrite=True, offScreen=True, format="qt", percent=100, compression=playblastFormat, quality=100, showOrnaments=False, viewer=False, filename=playblastFileName, height=1080, width=1920)
pass
wnd = BR_Main()
wnd.show()
@culvant
Copy link

culvant commented Jul 12, 2021

Hi, its giving the following error in Maya 2018;

Error: No module named PySide

Traceback (most recent call last):

File "", line 25, in

ImportError: No module named PySide

@WesleyE
Copy link
Author

WesleyE commented Jul 12, 2021

Hi @culvant,

I stopped working entirely in this field so I'm not familiar with the changes in Maya 2018. After a quick Google I think you should be fine to replace from PySide import QtCore, QtGui with from PySide2.QtCore import QtCore, QtGui. Although its a different version, I don't think I used anything exotic, so it might just work. Let me know if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment