def importAovs(self): """import aovs into scene""" LayersInfo = pickle.load( open( self.aovsPath.path, "rb") ) mc.refresh( su = 1 ) for ao in LayersInfo.keys(): aov.create( ao, LayersInfo[ao]['name'], LayersInfo[ao]['type'], LayersInfo[ao]['enabled'] ) mc.refresh( su = 0 )
def renderOcc( motionBlur, group ): #setup render settings curFile = mfl.currentFile() dead = dl.Deadline() defRenderGlobals = mn.Node( 'defaultRenderGlobals' ) defRenderGlobals.a.currentRenderer.v = 'arnold' defRenderGlobals.a.animation.v = True defRenderGlobals.a.extensionPadding.v = 4 defRenderGlobals.a.putFrameBeforeExt.v = 1 defArnoldRenderOptions = mn.Node( 'defaultArnoldRenderOptions' ) defArnoldRenderOptions.a.motion_blur_enable.v = motionBlur defArnoldRenderOptions.a.motion_steps.v = 3 mn.Node( 'defaultArnoldDriver' ).a.aiTranslator.v = 'exr' attrs = [ 'ignoreAtmosphere', 'ignoreLights', 'ignoreShadows', 'ignoreDisplacement', 'ignoreBump' ] for a in attrs: defArnoldRenderOptions.attr( a ).v = 1 defArnoldRenderOptions.a.AASamples.v = 3 attrs = [ 'GIDiffuseSamples', 'GIGlossySamples', 'GIRefractionSamples', 'sssBssrdfSamples', 'volumeIndirectSamples' ] for a in attrs: defArnoldRenderOptions.attr( a ).v = 0 #TURN OFF ALL CAMERAS RENDERABLES for c in mn.ls( typ = 'camera' ): c.a.renderable.v = 0 #TURN CAMERA TO RENDER ON currCam = getCurrentCamera() currCam.shape.a.renderable.v = 1 #TURN OFF ALL IMAGE PLANES imagePlanes = mn.ls( exactType = 'imagePlane' ) for i in imagePlanes: i.a.alphaGain.v = 0 #set attributes on for all the meshes attrs = [ 'castsShadows', 'receiveShadows', 'primaryVisibility', 'motionBlur' ] for n in mn.ls( typ = 'mesh' ): for a in attrs: n.attr( a ).v = 1 #Turn OFF ALL AOVS for ao in aov.aovsInScene(): ao.a.enabled.v = 0 #Create OCC AOV aovNode = mn.Node( 'aiAOV_Aov_OCC' ) if not aovNode.exists: aovNode = aov.create( aovName = 'Aov_OCC' , aovType = 6 ) #Turn On OCC AOV aovNode.a.enabled.v = 1 createShader(aovNode) #write job for render settings = sti.Settings() gen = settings.General renderPath = 'R:/' if gen: renderPath = gen[ "renderpath" ] if not renderPath.endswith( '/' ): renderPath += '/' assOrShot = prj.shotOrAssetFromFile( curFile ) name = '' filename = '' if assOrShot: if assOrShot.type == 'shot': if gen.has_key( 'greypath' ): filePrefix = renderPath + gen[ "greypath" ] else: filePrefix = renderPath + '/<project>' + '/' + '<sequence>' + '/' + '<shot>' + '/Grey/' + '<RenderLayerVersion>' + '/Grey' #replace <tags> to final names filePrefix = getFilePrefixFromTags( filePrefix, assOrShot ) else: print 'Cant Detect current shot :(, please save scene if its is a shot' return if '<RenderLayerVersion>' in filePrefix: versionNumber = _getVersionNumber( filePrefix.split( '<RenderLayerVersion>' )[0] ) filePrefix = filePrefix.replace( '<RenderLayerVersion>', 'v' + str(versionNumber).zfill( 4 ) ) filename = filePrefix + '.' + ('?'*4) + os.path.splitext( filename )[1] name = assOrShot.project.name + ' - ' else: print 'please save scene in project' return curFile.newVersion() curFile.save() Job = dl.Job( 'defaultRenderLayer', { 'Plugin' : 'MayaBatch', 'Group' : group, 'Pool' : '', 'Frames' : str( int( mc.playbackOptions( q = True, min = True ) ) ) + "-" + str( int( mc.playbackOptions( q = True, max = True ) ) ), 'Comment' : '', 'InitialStatus' : 'Active', 'Whitelist' : '', 'Name' : name + curFile.name + ' - ' + 'Grey', 'OutputFilename0' : filename, 'Priority' : 50, 'ChunkSize' : 5, 'OutputDirectory0': filename },{'CommandLineOptions' : '-rl ' + 'defaultRenderLayer' + ' -mr:art ', 'UsingRenderLayers' : 1, #'ProjectPath' : projPath, 'RenderLayer' : 'defaultRenderLayer', 'OutputFilePrefix' : filePrefix, 'OutputPath' : filename }, curFile ) Job.write() dead.runMayaJob( Job ) #TURN ON IMAGE PLANES for i in imagePlanes: i.a.alphaGain.v = 1