def selectDeptVer(self, direct=False):
     fromScene = self.chkFromScene()
     self.curDept = mc.optionMenu('cmbDepts', q=1, v=1)
     mc.optionMenu('cmbDeptVer', e=1, sl=1)
     mc.optionMenu('cmbRetake', e=1, sl=1)
     if not self.curDept in ["LAYOUT", "BLOCKING", "ANIMATION"
                             ] and not direct:
         mc.optionMenu('cmbCategory', e=1, sl=1)
     if fromScene:
         self.mayaShot = ppc.MayaShot(silent="disabled")
         if not self.curDept in ["LAYOUT", "BLOCKING", "ANIMATION"
                                 ] and not direct:
             curDeptCat = deptDict[self.mayaShot.deptShort][1]
             mc.optionMenu('cmbCategory', e=1, v=curDeptCat)
         if self.mayaShot.validShot:
             curDeptVer = int(self.mayaShot.deptVer)
             curDeptShort = self.mayaShot.deptShort
             curCategory = deptDict[curDeptShort][1]
             uiCategory = mc.optionMenu('cmbCategory', q=1, v=1)
             if self.curDept in ["LAYOUT", "BLOCKING", "ANIMATION"]:
                 mc.optionMenu('cmbRetake', e=1, v=curDeptVer)
             else:
                 if curCategory == uiCategory:
                     mc.optionMenu('cmbDeptVer', e=1, v=curDeptVer)
         wsPath = self.mayaShot.shotPath
     else:
         curDeptShort = self.getCurDeptShort()
         res = "rig" if curDeptShort in midAstDepts else "texture"
         cmsObj = self.getCmsObj(res, curDeptShort)
         wsPath = cmsObj.wsPath
     if self.curDept in ["LAYOUT", "BLOCKING", "ANIMATION"]:
         retakes = utils.findLastRetake(wsPath, "ma", True)
         if retakes:
             mc.optionMenu('cmbRetake', e=1, v=retakes[-1])
     self.loadVersions()
 def setDept(self, fromScene=True):
     self.mayaShot = ppc.MayaShot(silent="disabled")
     if self.mayaShot.validShot and fromScene:
         curDeptShort = self.mayaShot.deptShort
         if curDeptShort in deptDict.keys():
             curDept = deptDict[curDeptShort][0].upper()
             mc.optionMenu('cmbDepts', e=1, v=curDept)
Exemplo n.º 3
0
def importCam():
    epsq = "sq000"
    shot = "sh000"
    stereo = False
    sel_cam = mc.optionMenu('cmb_camList',q=1,v=1)
    typ = sel_cam[-1]
    mayaShot = ppc.MayaShot()
    if not mayaShot.validShot:
        msgWin("Error", "Invalid Shot or Project", True)
    else:
        epsq = mayaShot.epSqName
        shot = mayaShot.shName
        stereo = mayaShot.projInfo.stereo
    importCamera(epsq, shot, stereo, typ)
Exemplo n.º 4
0
def importAudio(silent = False):
    mayaShot = ppc.MayaShot()
    if not mayaShot.validShot:
        msgWin("Error", "Invalid Shot or Project", silent)
        return False
    audioNodes = mc.ls(typ = "audio")
    if audioNodes:
        for aud in audioNodes:
            mc.delete(aud)
    audFilePath = os.path.join((mayaShot.projInfo.mapDrive + "/"), mayaShot.projInfo.soundFldr, mayaShot.epSqName, "sc-%s.wav"%mayaShot.shot)
    if os.path.exists(audFilePath):
        audnode = mc.sound(file = audFilePath, offset = 101, n = "%s%s_aud"%(mayaShot.epSqName, mayaShot.shName))
        setAudio = 'global string $gPlayBackSlider; timeControl -e -ds 1 -s "%s" $gPlayBackSlider;' % audnode
        mel.eval("%s" % setAudio)
        msgWin("Message", "Successfully imported audio : %s"%audFilePath, silent)
        return True
    else:
        msgWin("Error", "Audio file does not exist : %s"%audFilePath, silent)
        return False
 def chkFromScene(self):
     mayaShot = ppc.MayaShot(silent="disabled")
     fromScene = False
     if mayaShot.validShot:
         fromScene = True
         curDeptShort = mayaShot.deptShort
         curDept = deptDict[curDeptShort][0]
         uiDept = mc.optionMenu('cmbDepts', q=1, v=1).lower()
         if not curDept == uiDept:
             fromScene = False
         curEpsq = mayaShot.epsqNum
         uiEpsq = mc.optionMenu('cmbEpisode', q=1, v=1)
         if not curEpsq == uiEpsq:
             fromScene = False
         curShot = mayaShot.shot
         uiShot = mc.optionMenu('cmbShot', q=1, v=1)
         if not curShot == uiShot:
             fromScene = False
     return fromScene
 def loadShots(self):
     self.mayaShot = ppc.MayaShot(silent="disabled")
     if self.mayaShot.validShot:
         self.shotNum = self.mayaShot.shot
     else:
         self.shotNum = mc.optionMenu('cmbShot', q=1, v=1)
         if not self.shotNum: self.shotNum = "001"
     menuItems = mc.optionMenu('cmbShot', q=True, ill=True)
     if menuItems: mc.deleteUI(menuItems)
     epsqNum = mc.optionMenu('cmbEpisode', q=1, v=True)
     excelPath = '%s/%s_%s%s_bld.xls' % (self.breakDownPath,
                                         self.projInfo.projShort,
                                         self.projInfo.epOrSeq, epsqNum)
     xlShots = utils.getXLShots(excelPath)
     shotIndex = 1
     if xlShots:
         xlShotList = sorted(xlShots.keys())
         for i in range(len(xlShotList)):
             mc.menuItem(label=xlShotList[i], p='cmbShot')
             if self.shotNum == xlShotList[i]:
                 shotIndex = i + 1
         mc.optionMenu('cmbShot', e=1, sl=shotIndex)
     self.selectDeptVer()
Exemplo n.º 7
0
def takePlayblast(silent = True, custom = False, customPath = None):
    renWidth = mc.getAttr("defaultResolution.width")
    renHeight = mc.getAttr("defaultResolution.height")
    aspRatio = renWidth/float(renHeight)
    width = renWidth/2 if renWidth > 960 else renWidth
    height = renHeight/2 if renWidth > 960 else renHeight
    mayaShot = ppc.MayaShot()
    if not mayaShot.validShot:
        msgWin("Warning", "Invalid Shot or Project", True)
        if not custom:
            return False
        else:
            viewport = getActiveViewport(silent)
            if not viewport: return False
            mc.setFocus(viewport)
            scCam = mc.modelPanel(viewport, q = True, cam = True)
            scCamSshp = mc.listRelatives(scCam, c = 1, s = 1, ni = 1)
            stereo = True if mc.nodeType(scCamSshp == "stereoRigCamera") else False
            soundName = "NoIdea"
    else:
        if round(aspRatio, 2) ==  1.78:
            width = 960
            height = 540
        else:
            width = mayaShot.projInfo.resWidth/2 if mayaShot.projInfo.resWidth > 1280 else mayaShot.projInfo.resWidth
            height = mayaShot.projInfo.resHeight/2 if mayaShot.projInfo.resWidth > 1280 else mayaShot.projInfo.resHeight
        soundName = "%s%s_aud"%(mayaShot.epSqName, mayaShot.shName)
        scCam = mayaShot.getSceneCamera(False)
        stereo = mayaShot.projInfo.stereo
        sceneCleanup(True)
    if not scCam or not mc.objExists(scCam):
        msgWin('Error', "Couldn't find a valid camera in the scene", silent)
        return False
    if stereo and custom:
        getCam = mc.confirmDialog(title = 'Select Camera', message = 'Which Stereo Camera do you want to take Playblast from?', button = ['Left','Center','Right','Cancel'], cb = 'Cancel', ds = 'Cancel')
        if getCam == 'Left':
            scCam = scCam.replace("_camCt", "_camLt")
        elif getCam == 'Right':
            scCam = scCam.replace("_camCt", "_camRt")
        elif getCam == 'Cancel':
            return False
    if mc.window('playBlastWindow', exists = 1): mc.deleteUI('playBlastWindow')
    if mc.windowPref ('playBlastWindow', exists = 1): mc.windowPref ('playBlastWindow', remove = 1)
    pbTmp = mc.window("playBlastWindow", wh = (1000, 700), te = 50, le = 50)
    mc.paneLayout()
    modPane = mc.modelPanel()
    mc.showWindow(pbTmp)
    mc.lookThru(scCam, modPane)
    mc.modelEditor(modPane, e=True, allObjects=0)
    mc.modelEditor(modPane, e=True, nurbsSurfaces=1, polymeshes=1,fluids=1,strokes=1)
    mc.modelEditor(modPane, e=True, da='smoothShaded')
    mc.modelEditor(modPane, e=True, av = True)
    sounds = mc.ls('%s*'%soundName, typ='audio')
    if not sounds:
        sounds = mc.ls(typ='audio')
    sound = sounds[0]  if sounds else ''
    st = mc.playbackOptions(q = True, ast = True)
    en = mc.playbackOptions(q = True, aet = True)
    blastPath = os.path.join(os.environ['TMP'], 'tempPlayblast.avi')
    if custom:
#        Find the highlighted range on timeSlider (if any)..
        aPlayBackSlider = mel.eval('$tmpVar=$gPlayBackSlider')
        times = mc.timeControl(aPlayBackSlider, q=True, rng=1)
        times = times.replace('"', '').split(':')
        if int(times[1]) != int(times[0]) +1 :  # 'll be currentTime & currentTime+1 evenif no range selected ==> Exclude that case!
            st = int(times[0])
            en = int(times[1]) -1
        finalPath = None
    else:
        st = 101
        en = 100 + mayaShot.frames
        finalPath = customPath if customPath else mayaShot.shotPath.replace(".%s"%mayaShot.projInfo.mayaExt, ".avi")
        saveVersion(finalPath)
    width = width*2
    height = height*2
    mc.playblast(st = st, et = en, fmt = 'movie', f = blastPath, s = sound, c = 'Lagarith', fo = True, orn = True, p = 50, qlt = 100, w = width, h = height)
    if finalPath:
        try:
            shutil.copyfile(blastPath, finalPath)
        except:
            msgWin("Error", "Error copying %s to %s"%(blastPath, finalPath), False)
    mc.deleteUI(pbTmp)
    return True
Exemplo n.º 8
0
def sceneCleanup(silent = True):
    mc.displayColor('headsUpDisplayLabels', 16, dormant=True)
    namespaces = mc.namespaceInfo(lon = True)
    if "Suleiman00s_pr01" in namespaces:
        mc.namespace(ren = ("Suleiman00s_pr01", "Suleiman00p_pr01"), f = True)
    mayaShot = ppc.MayaShot()
    if not mayaShot.validShot:
        msgWin("Error", "Invalid Shot or Project", silent)
        return False
    epsq = mayaShot.epSqName
    shot = mayaShot.shName
    stereoCams = []
    mc.setAttr("defaultResolution.width", mayaShot.projInfo.resWidth)
    mc.setAttr("defaultResolution.height", mayaShot.projInfo.resHeight)
    mc.setAttr("defaultResolution.deviceAspectRatio", mayaShot.projInfo.aspectRatio)
    camPattern = "(ep|sq)[0-9]{3}sh[0-9]{3}([a-b]{1})?_camCt"
    camName = "%s%s_camCt" % (epsq, shot)
    scCams = mc.ls(type = "camera")
    renCams = []
    for cam in scCams:
        camTr = mc.listRelatives(cam, p = True)
        pMatch = re.search(camPattern, camTr[0])
        if pMatch:
            renCams.append(camTr[0])
    if not renCams:
        msgWin("Error", "Couldn't find a valid camera", silent)
        return False
    if len(renCams) > 1:
        msgWin("Error", "Too many cameras in the scene.\nPlease delete unwanted cameras", silent)
        return False
    if not renCams[0] == camName:
        mc.rename(renCams[0], camName)
    if mayaShot.projInfo.stereo:
        stereoCams = mc.listRelatives(camName, c = 1, typ = 'transform')
        for stCam in stereoCams:
            nodeTyp = mc.nodeType(stCam, i = True)
            if "constraint" in nodeTyp:
                continue
            if mc.getAttr(stCam + ".tx") < 0:
                mc.rename(stCam, camName.replace("_camCt", "_camLt"))
            else:
                mc.rename(stCam, camName.replace("_camCt", "_camRt"))
        camShape = "%sCenterCamShape" % camName
    else:
        camShape = "%sShape" % camName
    camShps = mc.listRelatives(camName, c = True, s = True)
    for shp in camShps:
        sMatch = re.search(camPattern, shp)
        if sMatch:
            mc.rename(shp, shp.replace(sMatch.group(0), camName))
        else:
            print "Unable to find correct name for %s" % shp
    camParent = mc.listRelatives(camName, p = True)
    if camParent:
        camParent = camParent[0]
    if not camParent in ["CAM", "Aim_camera", "Ctl_Camera", "camera_group"]:
        if not mc.objExists("CAM"):
            mc.group(n = "CAM", em = True)
        try:
            mc.parent(camName, "CAM")
        except:
            pass
    camTopGrp = mc.listRelatives("CAM", p = True)
    if not camTopGrp == "CAMERAS":
        if not mc.objExists("CAMERAS"):
            mc.group(n = "CAMERAS", em = True)
        try:
            mc.parent("CAM", "CAMERAS")
        except:
            pass
    huds = ["HUDShotName", "HUDUserName", "HUDfocalLength", "HUDFrameNo"]
    for hud in huds:
        if mc.headsUpDisplay(hud, ex = True):
            mc.headsUpDisplay(hud, rem = True)
    focLen = mc.getAttr("%s.focalLength" % camShape)
    mc.headsUpDisplay('HUDfocalLength', s = 5, b = 1, bs = 'small', l = 'focalLength: %s' % focLen, lfs = 'large')
    mc.headsUpDisplay('HUDShotName', s = 6, b = 1, bs = 'small', l = 'shot: %s%s' % (epsq, shot), lfs = 'large')
    #username = os.environ['USERNAME']
    #mc.headsUpDisplay('HUDUserName', s = 7, b = 1, bs = 'small', l = 'user: %s' % username, lfs = 'large')
    mc.headsUpDisplay('HUDFrameNo', s = 8, b = 1, bs = 'small', l = 'frame: ', lfs = 'large', c = 'import maya.cmds as mc; mc.currentTime(q = True)', atr = True)
    scnCameras = [camName]
    if stereoCams: scnCameras.extend(mc.listRelatives(camName, c = 1, typ = 'transform'))
    for scnCam in scnCameras:
        mc.camera(scnCam, e = 1, dfg = 0, dgm = 1, dr = 1, ovr = 1.1)
        if mayaShot.projInfo.stereo and scnCam.endswith("_camCt"):
            scnCam = scnCam + "CenterCam"
        mc.setAttr('%sShape.displayGateMaskOpacity' % scnCam, l = 0)
        mc.setAttr('%sShape.displayGateMaskOpacity' % scnCam, 1)
        mc.setAttr ('%sShape.displayGateMaskColor' % scnCam, l = 0)
        mc.setAttr ('%sShape.displayGateMaskColor' % scnCam, 0, 0, 0)
    if mc.objExists('hudFix_node'):
        mc.delete('hudFix_node')
    mayaShot.moveAssetsToGrps()
    shotFrames = mayaShot.frames
    mc.playbackOptions(min=101, max=100+int(shotFrames), ast=101, aet=100+int(shotFrames))
    om.MGlobal.displayInfo("Scene cleaned up.")
 def saveFile(self, local=False):
     pBlast, cchChk, pbStat = False, False, True
     cmsObj = self.getCmsObj()
     if cmsObj.deptShort in ["ly", "bk", "an"]:
         pBlast = mc.checkBox("chkPlayblast", q=1, v=1)
         if pBlast:
             viewport = utils.getActiveViewport()
             if not viewport:
                 utils.msgWin(
                     "Error",
                     "Couldn't get active viewport. Please\nactivate viewport and try again.",
                     False)
                 return
         cchChk = mc.checkBox("chkCache", q=1, v=1)
         if cchChk:
             cacheDataObj = ppc.CacheDataXml()
             cacheExportError = cacheDataObj.checkExportErrors(False)
             if cacheExportError:
                 return
     mayaShot = ppc.MayaShot(silent="disabled")
     if not mayaShot.validShot:
         utils.msgWin("Error", "Not a valid shot", False)
         return
     if not (mayaShot.deptShort == cmsObj.deptShort):
         msg = "Scene department does not match the dept selected in manager."
         utils.msgWin("Error", msg, False)
         return
     if not (mayaShot.epSqName == cmsObj.epsq
             and mayaShot.shName == cmsObj.shot):
         msg = "Scene shot number does not match the shot selected in manager."
         msg += "\nDo you want to save using the shot number selected in manager?"
         msg += "\nThis will rename camera and obtain frames from breakdown list."
         conf = mc.confirmDialog(t="Warning",
                                 m=msg,
                                 button=['Save', 'Cancel'],
                                 cancelButton='Cancel',
                                 dismissString='Cancel')
         if conf == 'Cancel':
             return
     if local:
         wsFileFldr = mc.fileDialog2(dialogStyle=1, fm=3)
         if wsFileFldr:
             newFilePath = os.path.join(
                 wsFileFldr[0], "%s.%s" % (cmsObj.fileName, cmsObj.ext))
             if os.path.exists(newFilePath):
                 utils.saveVersion(newFilePath)
             mc.file(rename=newFilePath)
             mc.file(save=True)
             blastPath = newFilePath.replace(".%s" % cmsObj.ext, ".avi")
         else:
             utils.msgWin("Error", "No folder selected", True)
             return
     else:
         wsFilePath = os.path.join(cmsObj.wsPath,
                                   "%s.%s" % (cmsObj.fileName, cmsObj.ext))
         utils.saveVersion(wsFilePath)
         mc.file(rename=wsFilePath)
         utils.sceneCleanup()
         mc.file(save=True)
         blastPath = None
     msg = "File successfully Saved"
     if pBlast:
         pbStat = utils.takePlayblast(True, False, blastPath)
     mc.refresh()
     if cchChk and not local:
         cacheDataObj = ppc.CacheDataXml()
         cacheDataObj.writeXML()
         msg = "File successfully Saved and Cached"
     if not pbStat:
         msg = msg + "\n\nThere were errors while taking the playblast.\nPlease check the script editor for details."
     utils.msgWin("Success", msg, False)
     self.loadVersions()