Example #1
0
def makeRigAsset(assetType=None,
                 charName=None,
                 rigType=None,
                 lockAllAttrs=True):
    sel = ma.ls(sl=True)
    animRig = sel[0]
    nameDataArray = [
        assetType, charName, rigType,
        ma.date(d=True),
        ma.date(t=True)
    ]
    stringDataArray = [
        "ASSET_TYPE", "CHAR_NAME", "RIG_TYPE", "CREATION_DATE", "CREATION_TIME"
    ]

    for stringData, nameData in zip(stringDataArray, nameDataArray):
        ma.addAttr(animRig, ln=stringData, dt="string", k=True)
        if nameData != None:
            if nameData == ma.date(d=True) or nameData == ma.date(
                    t=True) or lockAllAttrs:
                ma.setAttr(animRig + "." + stringData,
                           str(nameData),
                           type="string",
                           l=True)
            else:
                ma.setAttr(animRig + "." + stringData,
                           str(nameData),
                           type="string")
Example #2
0
def loadTestRoom():

    needSave = cmds.file(q=True, modified=True)
    testroomfile = mel.eval('getenv SLiBLib;') + '/scene/SLiB_ShaderTestRoom_hdri.ma'
    testroomdestination = cmds.workspace(query = True, fullName = True)
    hdrifile = mel.eval('getenv SLiBLib;') + '/scene/TestRoom.hdr'
    bgfile = mel.eval('getenv SLiBLib;') + '/scene/BG_grey.png'
    checkerfile = mel.eval('getenv SLiBLib;') + '/scene/Checker.png'
    
    if needSave:
        cmds.SaveScene()
    else:
        pass
    
    cmds.file( f=True, new=True )
    cmds.file( testroomfile, o=True )
    cmds.setAttr('redshiftDomeLightShape1.tex0', str(hdrifile), type="string")
    cmds.setAttr('redshiftDomeLightShape1.tex1', str(bgfile), type="string")
    cmds.setAttr('RS_CheckerBall_File01.fileTextureName', str(checkerfile), type="string")
    cmds.setAttr('RS_CheckerRoom_File01.fileTextureName', str(checkerfile), type="string")
    t = cmds.date()
    xsplit = t.split('/')
    y = xsplit[-1]
    name = 'RS_Testroom_' + t + '.ma'
    savename1 = name.replace (" ", "_")
    savename2 = savename1.replace ("/", "")
    savename3 = savename2.replace (":", "")
    cmds.file( rename=savename3 )
    cmds.file(save=True, type='mayaAscii' )
 def UPDATECONTROLLERfn(self,*args):
     global NEWNAMEtxtfld, CONTROLLERtxtscr, CACHEsrvr, IMAGEimg, SCRSHTPANEL2var
     if cmds.textScrollList(CONTROLLERtxtscr,q=True,si=True)==None:
         cmds.confirmDialog(icon='warning',title='Message',message='Controller not selected', button=['Ok'])
         cmds.error('NO CONTROLLER SELECTED')  
         
     REPLYvar=cmds.confirmDialog(icon='question', title='Message',message='This will overwrite the selected file. Proceed?', button=['Yes','No'])    
     if REPLYvar=='Yes':
         cmds.select(cl=True)
         cmds.setFocus(SCRSHTPANEL2var)
         MODELPANELvar=apiUI.M3dView.active3dView()
         IMAGEvar=api.MImage()
         MODELPANELvar.readColorBuffer(IMAGEvar, True)            
         IMAGEvar.writeToFile(CACHEsrvr+'/library/'+'ctrlimg_'+cmds.textScrollList(CONTROLLERtxtscr,q=True,si=True)[0][8:]+'.png','png')
         
         cmds.file(rename=CACHEsrvr+'library/'+cmds.textScrollList(CONTROLLERtxtscr,q=True,si=True)[0]+'.ma')
         cmds.file( save=True, type='mayaAscii' )  
         
         if os.path.isdir('C:/workspace/library/')==False:
             os.mkdir('C:/workspace/library/')
         TIMEvar=cmds.date(f='YYYYYYMMDDhhmmss')  
         cmds.file(rename='C:/workspace/library/'+cmds.textScrollList(CONTROLLERtxtscr,q=True,si=True)[0]+'_'+TIMEvar+'.ma')
         cmds.file( save=True, type='mayaAscii' )  
     else:
         cmds.error('CANCELLED BY USER')
     return
Example #4
0
 def __addHeader(cls, content):
     contentList = [
         cls.HEADER,
         r"//",
         r"// Author:       %s" % mel.eval(r'getenv("USER")'),
         r"// Date:         %s" % cmds.date(),
         r"//",
         r"//XGIP:VERSION: %s" % cls.buildVersion,
     ]
     contentList.append(content)
     return '\n'.join(contentList)
Example #5
0
def writeLog(refFileName, pathName, scenePath, backupName):

    #log
    #get parent folder
    scenePath = cmds.file(q=True, sn=True)
    currentFolder = scenePath.rsplit('/', 1)[0]
    #machine name
    computer = platform.node()
    #Create A String Array With Test Data
    filePath = '%s/log/%s.mb.log' % (currentFolder, refFileName)
    if not os.path.exists('%s/log' % (currentFolder)):
        os.makedirs('%s/log' % (currentFolder))
    text_file = open(filePath, 'a')
    #Print Array To File
    log = '%s\nPublished to		%s\nPublished from	  %s\nBackup file	%s\nMachine			 %s\n\n' % (
        cmds.date(), pathName, scenePath, backupName, computer)
    text_file.write(log)
    #Close File
    text_file.close()
Example #6
0
def add_attr_id(derivative, output_path):

    selectedObj = cmds.ls(sl=1, dag=1, s=1)

    ###########################

    # Project directory to be created

    projectPath = output_path + "alembic_cache/"

    ###########################

    sceneName = cmds.file (q=True, sn=True, shn=True).split('.mb')
    path = projectPath + str(sceneName[0]) + "//shaders//"
    pathFile = projectPath + str(sceneName[0]) + "//" + str(sceneName[0]) + derivative + ".abc"

    for i in selectedObj:
        aRandom = random.randint(0, 5000)
        bRandom = random.randint(0, 5000)
        cRandom = random.randint(0, 5000)
        id = aRandom * bRandom * cRandom
        time = cmds.date(f="YYYYYYMMDDhhmmss")
        id = "id" + str(id) + time
        attributes = cmds.listAttr(i)
        if "Alembic_id" in attributes:
            cmds.setAttr(i + ".Alembic_id", id, type="string")
        else:
            cmds.addAttr(i, longName='Alembic_id', dt="string")
            cmds.setAttr(i + ".Alembic_id", id, type="string")

        id = cmds.getAttr(i + ".Alembic_id")
        interO = cmds.getAttr(i + '.intermediateObject')
        if interO != True:
            shaders_export(id, i, path)

    attrName = "Alembic_id"
    attrName_2 = "Face_id"
    frameRange = [str(cmds.playbackOptions(min=True, q=True)), str(cmds.playbackOptions(max=True, q=True))]

    alembic_export(selectedObj, frameRange[0], frameRange[1], pathFile, attrName, attrName_2)
Example #7
0
def putFileInfo(fType = "", wsNum = 000, note = "", *args):
    """
    modifies the open scene's file info:
        info keys that will change: 'FILETYPE', 'USER', 'WORKSHOP', 'DATE', 'CHARLX_NOTE'
    Args:
        fType (string): "geo", "rig", "lgt", "anm", "fx", ["mtl"?]
        [user will get info from open scene]
        wsNum (int, 3pad): workshop num (###)
        [date will get from open scene]
        note (string): some text string
    Return: 
        none
    """
    user = mel.eval("getenv USER")
    date = cmds.date()

    cmds.fileInfo("FILETYPE", fType)
    cmds.fileInfo("USER", user)
    cmds.fileInfo("WORKSHOP", wsNum)
    cmds.fileInfo("DATE", date)
    cmds.fileInfo("CHRLX_NOTE", note)

    FPS = ""
    RESW = 1920
    RESH = 1080
    FRANGE = "1-200"

    if fType == "anm" or fType == "lgt" or fType== "fx":
        FPS = cmds.currentUnit(q=True, time=True)
        cmds.fileInfo("FPS", FPS)

        RESW = cmds.getAttr("defaultResolution.width")
        RESH = cmds.getAttr("defaultResolution.height")
        cmds.fileInfo("RESOLUTION", "{0}-{1}".format(RESW, RESH))

        FRANGEMIN = cmds.playbackOptions(q=True, min=True)
        FRANGEMAX = cmds.playbackOptions(q=True, max=True)
        cmds.fileInfo("FRAMERANGE", "{0}-{1}".format(FRANGEMIN, FRANGEMAX))
Example #8
0
def makeBuildings(*args, **kwargs):
    checktime = cmds.date()
    print('Before faces:')
    print(checktime)
    faces = cmds.polyEvaluate(f=True)
    print(faces)
    checktime = cmds.date()
    print('After faces:')
    print(checktime)
    for i in range(0, faces):
        cmds.delete(ch=True)
        size1 = random.random()
        while size1 < 0.2:
            size1 = random.random()
        size2 = random.random()
        while size2 < 0.2:
            size2 = random.random()
        checktime = cmds.date()
        print(checktime)
        cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                              kft=False,
                              ltz=0,
                              ls=(size1, size2, 0))
        checktime = cmds.date()
        print(checktime)
        chance = random.randint(0, 100)
        BigB = cmds.textField(BigBuildingChance, query=True, text=True)
        int_BigB = int(BigB)
        if chance < int_BigB:
            print(i)
            height = random.randint(7, 10)
            print(height)
            chance = random.randint(0, 2)
            if chance == 1:
                size = random.random()
                while size < 0.4:
                    size = random.random()
            else:
                size = 1
            checktime = cmds.date()
            print(checktime)
            cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                  kft=False,
                                  ltz=height,
                                  ls=(size, size, 0))
            checktime = cmds.date()
            print(checktime)
            chance = random.randint(0, 100)
            spire = cmds.textField(SpireChance, query=True, text=True)
            int_spire = int(spire)
            if chance < int_spire:
                checktime = cmds.date()
                print(checktime)
                cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                      kft=False,
                                      ltz=height / 2,
                                      ls=(0, 0, 0))
                checktime = cmds.date()
                print(checktime)
            else:
                checktime = cmds.date()
                print(checktime)
                cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                      kft=False,
                                      ltz=height / 2,
                                      ls=(size, size, 0))
                checktime = cmds.date()
                print(checktime)
        else:
            print(i)
            height = random.randint(1, 2)
            print(height)
            size = 1
            checktime = cmds.date()
            print(checktime)
            cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                  kft=False,
                                  ltz=height,
                                  ls=(size, size, 0))
            checktime = cmds.date()
            print(checktime)
            chance = random.randint(0, 100)
            height = random.randint(1, 2)
            House = cmds.textField(HouseChance, query=True, text=True)
            int_house = int(House)
            if chance < int_house:
                chance = random.randint(0, 2)
                if chance == 1:
                    checktime = cmds.date()
                    print(checktime)
                    cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                          kft=False,
                                          ltz=height,
                                          ls=(size, size / 2, 0))
                    checktime = cmds.date()
                    print(checktime)
                else:
                    checktime = cmds.date()
                    print(checktime)
                    cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                          kft=False,
                                          ltz=height,
                                          ls=(size / 2, size, 0))
                    checktime = cmds.date()
                    print(checktime)
            else:
                checktime = cmds.date()
                print(checktime)
                cmds.polyExtrudeFacet('landscape.f[%s]' % i,
                                      kft=False,
                                      ltz=height,
                                      ls=(size, size, 0))
                checktime = cmds.date()
                print(checktime)
Example #9
0
def version():

    filename = mc.file(q=True, sn=True)

    charvalue = filename.split('/')

    # Verifier que l'on est dans le projet

    if not project_name in charvalue:

        sys.exit('You are not working in the Project !!')

    # Sortir l'emplacement du fichier seulement

    file_path = charvalue[:-1]
    filepath = '/'.join(file_path)
    path_versions = os.listdir(filepath)

    print(path_versions)

    print('charvalue  =  ' + str(charvalue))
    print('file_path  =  ' + str(file_path))
    file_path = '/'.join(charvalue)

    filevalue = path_versions[-1].split('_')

    indexing = filevalue[-1].split('.')

    indexingbis = int(indexing[0])

    indexingbis += 1

    print(indexingbis)

    indexingbis = padding_numbers.padder(indexingbis, pad)

    indexing.pop(0)
    indexing.insert(0, indexingbis)
    indexing = '.'.join(indexing)

    filevalue.pop(-1)
    filevalue.append(indexing)

    filevalue = '_'.join(filevalue)

    charvalue.pop(-1)
    charvalue.append(filevalue)
    charvalue = '/'.join(charvalue)

    print(charvalue)
    print(filevalue)

    mc.file(rename=charvalue)

    date = mc.date()
    mc.fileInfo('creator', pc_name)
    mc.fileInfo('date', date)

    mc.file(save=True, type='mayaAscii')

    new_name = charvalue

    return new_name
Example #10
0
# Where The Render Batch Script Will Be Generated
globalPath = "A:\\01prj\\XYZ\\prod\\assetbuildpub\\fx_assets\\BRScript\\"
print(globalPath)
# Getting The Maya File Path, Since The Batch Script Expects "" Thus Adding
mayaFilePath = "\"" + cmds.file(query=True, sceneName=True) + "\""
# Windows Path Replacing "/" With "\", Skip If Not Required
mayaFilePath = mayaFilePath.replace("/", "\\")
# Removing Some Character From The String & Adding Render Folder Location
# This Step Is Custom, Depends On How The Project Is Set, Change As Per Need
rndrFilePath = mayaFilePath[:44] + "/fx_renderLayers/v000\""
# Windows Path Replacing "/" With "\", Skip If Not Required
rndrFilePath = rndrFilePath.replace("/", "\\")

# Getting User Name, Uppercase All Letters & Keeping Only First And Last
# Character
userName = getpass.getuser()
userName = userName.upper()
userName = userName[0:1] + userName[-1:]

# The Batch File Will Have A Different Name Everyday, Thus Getting Date &
# Adding User Name With It
fileName = cmds.date(format="DD•MM•YYYY" + "_" + userName)

# Generating Batch File Also Appending Lines
fileHandle = open(globalPath + fileName + ".bat", "a+")

# Adding Lines One After Another, Thats How Maya Accepts The Batch File
fileHandle.write(renDir + " -r file -rd " + rndrFilePath + " " + mayaFilePath)
fileHandle.write("\n")
fileHandle.close()
Example #11
0
    def makeBatchFile(self, fileList):
        """
        Make batch render file, detecting appropriate type for the host OS.
        1. Add all given file names in fileList to the batch script
        2. Launch the script if told to. 
        """

        saveFolderorg = cmds.getAttr('Girl_settings.scene_path')
        saveFolderorg = saveFolderorg + os.altsep

        saveFolder = saveFolderorg.replace('\\', '/')
        saveFolder = saveFolder.replace('//', '/')

        sceneFileBaseName = cmds.getAttr('Girl_settings.scene_filename')
        batchFileName = saveFolder + sceneFileBaseName + '_render'
        GirlPath = cmds.getAttr('Girl_settings.Girl_path') + os.altsep
        guiMode = cmds.getAttr('Girl_settings.render_interface',
                               asString=True) == 'GUI'
        threads = cmds.getAttr('Girl_settings.render_threads')
        priority = cmds.getAttr('Girl_settings.render_priority', asString=True)

        GirlPath = GirlPath.replace('/', '\\')
        GirlPath = GirlPath.replace('\\\\', '\\')

        servers = self.getNetworkServers()

        # scale 0...5 to -9...6 - keeping normal at 0
        niceValue = (cmds.getAttr('Girl_settings.render_priority') - 3) * 3

        if guiMode:
            GirlPath += 'girlviewer'
        else:
            GirlPath += 'GirlConsole'

        if os.name == 'nt':
            GirlPath += '.exe'
            # windows batch file
            batchFileName += '.bat'
            try:
                fh = open(batchFileName, 'wb')
                fh.write(':: Girl batch render file generated by GirlMaya ' +
                         cmds.date() + os.linesep)
                fh.write('@Echo off' + os.linesep)

                cmdPrefix = str()
                if guiMode:
                    cmdPrefix = 'start /WAIT /%s' % priority
                else:
                    cmdPrefix = 'start /WAIT /MIN /%s' % priority

                for file in fileList:
                    ccmd = '%s %s %s"%s"' % (cmdPrefix, GirlPath, servers,
                                             file)
                    fh.write(('echo Rendering file %s' % file) + os.linesep)
                    fh.write(ccmd + os.linesep)

                fh.close()
            except:
                OpenMaya.MGlobal.displayError(
                    'Could not write render batch file')
                raise

        else:
            #unix bash script
            batchFileName += '.sh'
            try:
                fh = open(batchFileName, 'wb')
                fh.write('#!/bin/bash' + os.linesep)
                fh.write('# Girl batch render file generated by GirlMaya ' +
                         cmds.date() + os.linesep)

                for file in fileList:
                    fh.write(('nice -n %i %s -t %i %s"%s"' %
                              (niceValue, GirlPath, threads, servers, file)) +
                             os.linesep)
                fh.close()
            except:
                OpenMaya.MGlobal.displayError(
                    'Could not write render batch file')
                raise

        if cmds.getAttr('Girl_settings.render_launch') == 1:
            try:
                if os.name == 'nt':
                    # windows
                    #os.spawnv(os.P_NOWAIT, batchFileName, [batchFileName] )
                    os.system('start cmd /c "%s"' % batchFileName)
                else:
                    # assuming linux, this probably won't work on OSX
                    os.system('(xterm -T "Girl Render" -e %s)&' %
                              batchFileName)
            except:
                OpenMaya.MGlobal.displayError("Failed to launch process\n")
                raise
Example #12
0
	def startRender(self): # Will also return time taken from start to finish in minutes, to 2 decimal places
	
		frameDataLog = [] #Stores a comprehensive list of each frame as it is rendered with a timestamp for initialisation
		frameDataStringLog = []#Stores a comprehensive string list of each frame as it is rendered with a timestamp for initialisation, for using in the render log
		frameDataLogTemp = [] #Stores frame information temporarily
	
		#ints
		framesRendered = 0 #Stores current amount of frames rendered for determining overall progress
		percentComplete = 0 #Stores the percentage to completion, also used to determine if render completed successfully
		#Strings
		frameDataString = "null" #Stores frame information
		renderStartTimeStamp = ma.date(t=True) #Stores the time in which the render function was first called
		#floats
		renderTimeStamp = 0.0 #Stores the time in which the render completed or was forcably stopped
		#startTimer
		renderTimer = ma.timer(startTimer = True)
	
	
		###WINDOW CREATION
		#createWindow to allow interupting of progress.
		ma.progressWindow(isInterruptable=1, t="aBRS_RENDER", status = "Rendering...")

		#begin rendering frames
		for frame in self._frameList:
			##Allow interuption to stop the render
			if ma.progressWindow(query=True, isCancelled = True):
				print "Render Cancelled by User."
				break
		
			#set current frame
			ma.currentTime(frame)
		
			#store frame data and timestamp for initialisation then print.
			frameDataLogTemp = [self._getCam(frame), frame, ma.date(t=True)] # A nice list storing frame information (incase of storage)
			frameDataString = "Camera: %s, Frame: %s, TimeStarted: %s" % (str(frameDataLogTemp[0]), str(frameDataLogTemp[1]), str(frameDataLogTemp[2]))
		
			#Store data in lists
			frameDataLog.append(frameDataLogTemp)
			frameDataStringLog.append(frameDataString)
		
			#print current string data to viewport
			print frameDataString
			
			"""RENDER OCCURS HERE"""
			
			#try as maya 2018 arnold render returns a runtime error when interuption is detected
			self.tryArnoldRender(frame)
			#Add to frames rendered
			framesRendered += 1
			#Get percentage according to rendered vs total frames
			percentComplete = self._renderPercentComplete(framesRendered)
			#Update the progress window
			ma.progressWindow( edit=True, progress=percentComplete )
		
		'''Rendering has finished - Closing procedures'''	  
	
		#End timer
		renderTimer = ma.timer(endTimer = True)
		#End Progress window
		ma.progressWindow(endProgress=1)
		#Store total render time
		renderTimeStamp = str(round(renderTimer/60, 2))
	
		#record values for log file
		self._lS_frameDataSTR = frameDataStringLog
		self._lS_frameData = frameDataLog
		self._lS_renderStartTime = renderStartTimeStamp
		self._lS_renderEndTime = ma.date(t=True)
		self._lS_renderTimeInMinutes = renderTimeStamp
		self._lS_renderCompletionSuccessful = percentComplete == 100
		self.storeRenderData()
	
	
		#Generate log
		self.generateRenderLog()
	
		return "Render Time in Minutes: " + str(renderTimeStamp)
import os
import shutil
import maya.cmds as cmds
from xml.dom.minidom import Document
import xml.dom.minidom as xd
from xml.etree.ElementTree import Element
import xml.etree.ElementTree as ET

PROJ_ROOT      = "E:\PythonStuff\RenderQueue"
UI_FILE        = PROJ_ROOT+"\RenderQueue_UI_v5.ui"
xmlPath        = "E:\PythonStuff\RenderQueue\queue.xml"
today          = str(cmds.date(t=True))
c              = 0 
class RenderQueue(object):
  
    def __init__(self):
        self._objectList    = []
        self._windowName = "RenderQueue"
        
        
        
    #Add files to the list    
    def submitFile(self):
        fileName=cmds.file(query=True,shn=True, l=True)[0]
        filePath=cmds.file(query=True, l=True)[0]
        frames = cmds.playbackOptions(q=True, max=True)
        playblastFlag = "Yes"
        imagePlaneFlag = "No"
        
        tree = ET.ElementTree(file=xmlPath)
        file_list = tree.getroot()
Example #14
0
    def begin(self):
        '''Pre build actions'''
        cmds.file(new=True, f=True)

        RIGLOG.debug('making rig nodes')
        self.setRigNameDefault()
        self.addRigNode()
        self.addMasterSet()

        #Make some top level nodes
        self.limbNode = cmds.createNode('transform', n='limbs', p=self.rigNode)
        self.geoNode = cmds.createNode('transform', n='geo', p=self.rigNode)
        self.skeletonNode = cmds.createNode('transform',
                                            n='skel',
                                            p=self.rigNode)

        # Setup visibility attrs
        plumin = cmds.createNode('plusMinusAverage',
                                 n=self.rigNode + 'Vis_plumin')

        #This kind of geo/skeleton/mesh hiding or showing mechanism is optional.
        #Some animators like it, some prefer ctrl+h, some prefer layers, etc.
        #geo
        geoattr = self.rigNode + '.geoVis'
        cmds.addAttr(self.rigNode,
                     ln='geoVis',
                     at='enum',
                     en='off:on:template:reference:seg',
                     k=True,
                     dv=1)
        cmds.setAttr(self.geoNode + '.overrideEnabled', 1)
        cmds.connectAttr(geoattr, self.geoNode + '.overrideVisibility')
        cmds.setAttr(plumin + '.operation', 2)
        cmds.setAttr(plumin + '.input1D[1]', 1)
        cmds.connectAttr(geoattr, plumin + '.input1D[0]')
        cmds.connectAttr(plumin + '.output1D',
                         self.geoNode + '.overrideDisplayType')
        cmds.setAttr(geoattr, 1)

        # rig
        rigattr = self.rigNode + '.rigVis'
        cmds.addAttr(self.rigNode,
                     ln='rigVis',
                     at='long',
                     max=1,
                     min=0,
                     k=True,
                     dv=1)
        cmds.setAttr(rigattr, 1)
        cmds.setAttr(self.limbNode + '.overrideEnabled', 1)
        cmds.connectAttr(rigattr, self.limbNode + '.overrideVisibility')

        # skel
        skelattr = self.rigNode + '.skelVis'
        cmds.addAttr(self.rigNode,
                     ln='skelVis',
                     at='long',
                     max=1,
                     min=0,
                     k=True,
                     dv=1)
        cmds.setAttr(self.skeletonNode + '.overrideEnabled', 1)
        cmds.connectAttr(skelattr, self.skeletonNode + '.overrideVisibility')

        #create the world offset
        offset = limbGen.WorldOffset()
        self.addLimb(offset)

        # rig book keeping attrs.
        # these can be useful later when debugging scenes, to know
        # where things came from and when.
        cmds.addAttr(self.rigNode, ln='rigVersion', dt='string', keyable=False)
        cmds.setAttr(self.rigNode + '.rigVersion',
                     self.rigVersion,
                     type='string')

        cmds.addAttr(self.rigNode, ln='buildDate', dt='string', keyable=False)
        cmds.setAttr(self.rigNode + '.buildDate', cmds.date(), type='string')

        cmds.addAttr(self.rigNode, ln='builtBy', dt='string', keyable=False)
        cmds.setAttr(self.rigNode + '.builtBy',
                     getpass.getuser(),
                     type='string')
Example #15
0
def phonemesKeyer(object):
    startTime = cmds.date(t=True)
    ### List of characters for which to generate mouth shapes
    Char_list = [
        'Basil', 'Berry', 'Berry_Tooth', 'Biva', 'Candice', 'Casimir',
        'Catchup', 'Catchup_Necklace', 'Edmund', 'Edmund_Bag', 'Grandma',
        'Grandpa', 'Loudo', 'Lucien', 'Margaret', 'Martis', 'Mary', 'Pico',
        'Pierrette', 'Rosie', 'Rosie_Yellow', 'Scout_Crown', 'Scout_Medal',
        'Scout_Whistle', 'Scoutbadger', 'Sourpuss', 'Woods_Crown',
        'Woodsy_Necklace', 'Woods_Medal', 'Woodsy', 'Woodsy_Splint'
    ]

    for charName in Char_list:
        ### Load References
        # Import Phonemes scenes assets
        cmds.file(
            "scenes    for charName in Char_list:/MouthShapes/Phonemes_Scene.ma",
            reference=True,
            type="mayaAscii",
            namespace='Phonemes_Scene')
        # Import Characters
        cmds.file('N:/02_SAISON_2/03_FABRICATION/ASSETS/Character/' +
                  charName + '/rigging/pub/BDG__Character__' + charName +
                  '__rigging.ma',
                  reference=True,
                  type="mayaAscii",
                  namespace=charName)
        print '\n/////////////////////////////////////////////'
        print '/////////////////////////////////////////////'
        print '////'
        print '//// 1. Character ' + charName + ' loaded ////'

        ## Regenerate UV tiles
        eval('generateAllUvTilePreviews;')

        ## Creating zero keys on bookmarks
        Phonem_keys = ['1', '10', '20', '30', '40', '50', '60', '70', '80']
        for i in Phonem_keys:
            cmds.setKeyframe(charName + ':face_A_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_O_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_CDGK_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_Fv_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_MBP_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_L_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_U_fac_ctl',
                             attribute='translateY',
                             v=0,
                             t=i,
                             itt='linear')

            ## Keying the phonemes
            cmds.setKeyframe(charName + ':face_A_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=10,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_O_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=20,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_CDGK_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=30,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_Fv_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=40,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_MBP_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=50,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_L_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=60,
                             itt='linear')
            cmds.setKeyframe(charName + ':face_U_fac_ctl',
                             attribute='translateY',
                             v=1,
                             t=70,
                             itt='linear')
        print '//// 2. Phonemes keyed ////'

        ### Get Head pos then Xform Cam to it ( not quite ready, will need to use the BBox to offset the CAM placement
        FKHead_pos = cmds.xform(charName + ':FKHead_M_CTRL',
                                query=True,
                                translation=True,
                                worldSpace=True)
        FKHead_posXYZ = FKHead_pos[0], FKHead_pos[1], 0
        #cmds.xform ( "Cam_offseter", t = FKHead_posXYZ )

        ## Playblast
        playblastPath = "scenes/MouthShapes/" + charName + "_phonemes"
        #        cmds.playblast ( filename = playblastPath, forceOverwrite = 1, format = "qt", viewer = 0,  startTime = 0, endTime = 90,  clearCache = 1,
        #        showOrnaments = 0, offScreen = 1, framePadding = 4, percent = 100, compression = "H.264", quality = 100 )
        print '//// 3. Playblast phoneme file generated for ' + charName + ' ////'

        ### Saving Phoneme Maya file
        # Unload Phonemes scenes assets
        cmds.file("scenes/MouthShapes/Phonemes_Scene.ma", removeReference=True)
        # Actual saving of file
        cmds.file(rename='scenes/MouthShapes/' + charName + '_Phonemes.ma')
        cmds.file(save=True, type='mayaAscii')
        print '//// 4. Maya Phoneme file generated for ' + charName + ' ////'

        ### Unload Reference
        cmds.file('N:/02_SAISON_2/03_FABRICATION/ASSETS/Character/' +
                  charName + '/rigging/pub/BDG__Character__' + charName +
                  '__rigging.ma',
                  removeReference=True)
        print '//// 5. Reference ' + charName + ' unloaded ////\n'

    endTime = cmds.date(t=True)
    print('//////         Phoneme Keyer process started at ' + startTime +
          '///// ')
    print('//////         Phoneme Keyer process completed at ' + endTime +
          '///// ')
    print '////'
    print '////////////////////////////////////////////////////////////////////////////////////////////'
    print '////////////////////////////////////////////////////////////////////////////////////////////\n'