Example #1
0
def createWinShotDirs(shotFolder, *args):
    """
    from the window, will create a shot folder structure 
    Args:
        shotFolder (string): the generic "shots" folder under the job [...SPOT/3d/shots]
    Return:
        None
    """

    num = cmds.textFieldGrp(swidgets["num"], q=True, tx=True)
    myChars = [int(s) for s in num
               if s.isdigit()]  # get list of int digits in num

    if len(myChars) != 3:  # if we don't have 3 digits. . .
        cmds.warning("You need to enter a 3 digit number for the shot!!")
        return ()

    shotType = cmds.radioButtonGrp(swidgets["version"], q=True, sl=True)
    if shotType == 1:
        sname = "shot"
    if shotType == 2:
        sname = "previs"

    name = "{0}{1}".format(sname, num)

    #here we compare that list of assets with our proposed name
    shots = cFuncs.getSpotShotList(shotFolder)
    if name in shots:
        cmds.confirmDialog(
            t="Name Exists!",
            m="There is already a shot of this name\nin this project! Please enter another."
        )
        return ()

    shotFolderObj = utils.PathManager(shotFolder)
    #---------------- restore this!!
    # jobDirectoryCreator.createShot(shotFolderObj.jobDirname, shotFolderObj.spotDirname, name)

    varName = cmds.textFieldGrp(swidgets["variant"], q=True, tx=True)

    thisShotFolder = cFuncs.fixPath(os.path.join(shotFolder, name))
    createVariantDirs(thisShotFolder, "anm", varName, *args)

    if cmds.window("createShotWin", exists=True):
        cmds.deleteUI("createShotWin")

    # refresh the shot win
    if cmds.window("shotWin", exists=True):
        #pth = utils.PathManager(shotFolder)
        import chrlx_pipe.shotWin as shotWin
        shotWin.populateWindow()
Example #2
0
def projectCheck():
    """
    if project is the correct schema (via chrlx.utils), then return "good", else return 'None'
    Args:
        none
    Return:
        string: "good" or None
    """
    proj = getCurrentProject()
    pm = utils.PathManager(proj)
    check = pm.spotSchema

    if check == 2:
        return("good")
    else:
        return(None)
Example #3
0
def incrementWS(name, namePath, fType, *args):

    """
        takes in some info from the window and returns the full path to the next increment
        
        Args:
        name (string): asset or var name (i.e. "man" or "variantA")
        namePath (string): main asset or var folder (ie. ". . .JOB/3d_assets/characters/NAME/" or "...3d/shots/SHOT/TYPE/VAR/")
        fType (string): "geo", "rig", "mtl", "anm", "lgt", "fx"
        
        Return:
        string: the full path to the new increment
    """

    if fType == "geo" or fType == "rig" or fType == "mtl":
        latestWsPath = getLatestAssetWS(name, namePath, fType)

    if fType == "lgt" or fType == "fx" or fType == "anm":
        latestWsPath = getLatestVarWS(namePath)
    
    #if latestWsPath = None, then create a first path for newFile
    if latestWsPath:
        folder, doc = os.path.split(latestWsPath)
        num = int(doc.rpartition("_v")[2].rstrip(".ma"))

        base = doc.rpartition("v")[0]
        incr = num + 1
        newDoc = base + "v{:0>3d}".format(incr)
        newFile = "{0}/{1}".format(folder, newDoc)

    else:
    #split this between shot and asset - get rid of fType join in newFile and prepend with job number for SHOT STUFF
        if fType == "geo" or fType == "rig" or fType == "mtl":
            wsFile = "{0}_{1}_ws_v001".format(name, fType)
            newFile = "{0}/{1}/workshops/{2}".format(namePath, fType, wsFile)
        if fType == "anm" or fType == "lgt" or fType == "fx":
            pm = utils.PathManager(namePath)
            # jobNumb = pm.jobNumber
            # jobType = pm.jobType
            # shotLabel = os.path.basename(pm.shotPath)
            # wsFile = "{0}{1}{2}_{3}_{4}_ws_v001".format(jobType, jobNumb, shotLabel, fType, name)
            # newFile = "{0}/workshops/{1}".format(namePath, wsFile)
            newFile = pm.getNextWorkshop()

    return newFile
Example #4
0
def getVarMaster(varPath, *args):
    """
    check whether theres an var master file and returns full path

    Args:
        varPath (string): the full path to the variant folder (.../3d/shots/VAR/TYPE/)
    Return:
        string: full path to the current master of the variant
    """
    varPath = fixPath(varPath)
    fType = os.path.basename(varPath.rpartition(r"/")[0])
    varName = os.path.basename(varPath)
    pm = utils.PathManager(varPath)
    if pm:
        shot = pm.shot
        masterFile = pm.getMaster()
        if os.path.isdir(varPath) and (os.path.basename(masterFile) in os.listdir(varPath)):
            return(masterFile)

    else: return(None)
Example #5
0
def createJobSpotIcon(currentProjectPath, iconType, *args):
    """
    Args:
        currentProjectPath (string): the path for the project your'e creating icon for
        iconType (string): "spotIcon" or "jobIcon" - determines where to put the image
    Return:
        None
    """

    result = cmds.confirmDialog(title="Create Icon", message="This will create a new icon for the {0}\nfrom the current open scene/frame.\nDo you want to proceed?\nNOTE: the other option is just to create\na 50x50px image and put it in appropriate folder\nJOB/3d_assets/ for jobIcon\nJOB/SPOT/3d/ for spotIcon".format(iconType), button=["yes", "no"], defaultButton="no", cancelButton="no", dismissString="no")

    pm = utils.PathManager(currentProjectPath)
    if pm.spotSchema == 2:
        if iconType == "spotIcon":
            name = fixPath(os.path.join(pm.spotPath, "3d", "spotIcon"))
        if iconType == "jobIcon":
            name = fixPath(os.path.join(pm.jobPath, "3d_assets", "jobIcon"))

        if os.path.isfile(name+".jpg"):
            ow = cmds.confirmDialog(title="Overwrite Existing?", message="An icon already exists. Should we overwrite?", button=["yes", "no"], defaultButton="no", cancelButton="no", dismissString="no")
            if ow=="no":
                return
            if ow=="yes":
                os.remove(name+".jpg")

        if result == "yes":
            im = cmds.playblast(filename = name, forceOverwrite = 1, orn = 0, fmt = "image", frame = cmds.currentTime(q=True), fp=4, v=0, c="jpg", wh=(154,154), p=100)
            nums = im.replace(".####", ".0000")
            base = im.rpartition(".####")
            os.rename(nums, base[0]+base[2])

        if result == "no":
            return

        if cmds.window("assetWin", exists=True):
            import chrlx_pipe.assetWin as ass
            ass.populateWindow()

        if cmds.window("shotWin", exists=True):
            import chrlx_pipe.shotWin as shotWin
            shotWin.populateWindow()
Example #6
0
def getLatestVarMaster(var, varPath, fType, *args):
    """
    returns path to latest PAST VERSION of master file for shot variant

    Args:
        var (string): variant name (ie. "carDriving2")
        varPath(string): the path to the variant folder (ie. ...3d/shots/SHOT/VARIANT)
        fType(string): the type of shot (ie. "anm", "lgt", "fx")
    Return:
        string (path): the full path to the latest variant master (ie. ..."3d/shots/myShot/tunaJumping/past_versions/myfilename_v001.ma)
    """
    pm = utils.PathManager(varPath)
    shot = pm.shot

    if var and varPath and fType:

        mst = fnmatch.filter(os.listdir("{0}/past_versions".format(varPath)), "{0}_{1}_{2}_v[0-9]*.ma".format(shot, fType, var))

        #find the highest number WS
        sortNum = 0
        sortMst = "" #the file name of the last workshop file
        try:
            for x in range(0, len(mst)):
                #strip off the .ma, then get things after "_v". note this breaks if not named correctly!
                num = int(mst[x].rpartition("_v")[2].rstrip(".ma"))
                if num > sortNum:
                    sortNum = num
                    sortMst = mst[x]
        except:
            pass
            
        if sortMst:
            return fixPath("{0}/past_versions/{1}".format(varPath,sortMst))
        else: 
            return None

    else:
        cmds.warning("chrlxFuncs.getLastAssetMasterVersion: you haven't given me all the args I need")
        return "Abort"
Example #7
0
def getLatestVarWS(varPath,*args):
    """
        -varPath = the full path the variant folder (...3d/shots/SHOT/TYPE/VAR)
    """
    # file name = T#####<spotLetter>shot010_anm_variant1.ma

    pm = utils.PathManager(varPath)
    jobNum = pm.jobNumber
    jobLetter = pm.jobType
    #print "+++++++ cFuncs.getLatestVarWS: \nshotName={0}\npathManager={1}".format(shotName, pm)
    fType = pm.shotType
    shotLabel = os.path.basename(pm.shotPath)
    varName = os.path.basename(varPath)
    wsBasename = "{0}_{1}_{2}".format(shotLabel, fType, varName)

    ws = fnmatch.filter(os.listdir("{0}/workshops".format(varPath)), "*{0}_ws_v[0-9]*.ma".format(wsBasename))

    #find the highest number WS
    sortNum = 0
    sortWS = "" #the file name of the last workshop file
    try:
        for x in range(0, len(ws)):
            #strip off the .ma, then get things after "_v". note this breaks if not named correctly!
            num = int(ws[x].rpartition("_v")[2].rstrip(".ma"))
            if num > sortNum:
                sortNum = num
                sortWS = ws[x]
    except:
#---------------- throw up the exception here        
        pass
        
    if sortWS:
        return "{0}/workshops/{1}".format(varPath,sortWS)
    else:
        print "found no workshop files for {0}".format(wsBasename)
        return None
Example #8
0
def chrlxFileOpen(filePath, *args):
    """
    opens the given file path with check whether the scene isn't being read properly because of the absence of the arnold plugin. 
    Looks whether the scene recognizes itself and if it doesn't, then offer option to resave the scene over itself 
    (with whatever options are in the current scene)
    if asset: workshops will increment,masters will overwrite, both will then open
    if shot: workshops will increment and open, master will NOT open
    Args:
        filePath (string): the full patht to the file we're trying to open
    Return:
        none

    """

    changed = cmds.file(q=True, modified = True)
    if changed:
        save = saveDialog()
        if save=="save":
            #save
            cmds.file(save=True)
            print "saving current. . . "
            
        elif save == "noSave":
            print "not saving current. . ."

        elif save=="cancel":
                cmds.warning("Cancelling open operation")
                return
    try:
        cmds.file(filePath, open=True, f=True)

    except Exception, e:
        print "this is the error", e
        # look for ""
        if fnmatch.filter(e, "*ai*"):
            # check if the file recognizes itself
            fileCheck = cmds.file(q=True, sceneName=True)
            # if not, call up the confirm dialog(?) and give option to save over or abort 
            if not fileCheck:
                result = cmds.confirmDialog(title="Arnold Plug-in Issue!", message="Do you want to increment (ws) or overwrite (mst)\n the scene WITHOUT the arnold elements?\nNOTE: You CANNOT work on shot master files!\n", button=["yes", "no"], defaultButton="no", cancelButton="no", dismissString="no")
                # if we say yes, determine type of shot and whether ws or master and act accordingly
                if result == "yes":
                    path = utils.PathManager(filePath)
                    if type(path)==utils.AssetPath:
                        # print "this is an asset"
                        if path.isWorkshop:
                            next = path.getNextWorkshop()
                            # rename scene to next and save
                            cmds.file(rename=next)
                            cmds.file(save=True, type="mayaAscii")
                        if path.isMaster:
                            # print "and we're in a master"
                            cmds.file(rename=filePath)
                            cmds.file(save=True, type="mayaAscii")
                    elif type(path)==utils.shotPath:
                        # print "this is a shot"
                        if path.isWorkshop:
                            # print "and we're in a workshop"
                            next = path.getNextWorkshop()
                            cmds.file(rename=next)
                            cmds.file(save=True, type="mayaAscii")
                        if path.isMaster:
                            print "and we're in a master"
                            cmds.confirmDialog(title="Sorry!", message="You need to get to a computer with Arnold!\n You're not allowed to mess with shot masters!")
                            cmds.file(new=True, f=True)
                    else:
                        # print "we're not in the pipeline"
                        cmds.file(rename=filePath)
                        cmds.file(save=True, type="mayaAscii")

                if result == "no":
                    cmds.file(new=True, force=True)
Example #9
0
def masterShot(var,
               varFolder,
               fType,
               batch=False,
               BG=False,
               importRefs=True,
               *args):
    """
    gets latest version of past_versions
    Args: 
        varName (string): variantName (ie. "defaultVariant")
        varFolder (string): the folder for the variant (i.e. rig folder, lgt var folder, etc)
        fType (string): the type of shot abbreviation ('lgt', 'anm', 'fx'), 
        batch (bool): for batch mode (no UI)
        BG (bool): render in background?
        importRefs (bool): should we import the references when mastering?

    Return:
        string: returns message for the confirm dialog in shot win
    """

    note = "mastering shot!"

    #clash check
    clash = cClash.clash(0)
    if clash:
        fix = cmds.confirmDialog(
            title="Clash Fix?",
            message=
            "Name clashes have been detected!\nSee script editor for details\nHow should we fix?",
            button=("Fix Automatically", "Fix Manually"),
            defaultButton="Fix Automatically",
            dismissString="Fix Manually",
            cancelButton="Fix Automatically")
        if fix == "Fix Manually":
            cClash.clash(0)
            return ("clash")
        else:
            cClash.clash(1)

    # below UI has "dict" attr that will grab a dictionary from masterWin ("note":str, "cam":bool, "shd":bool, "rig":bool). use these vals to turn on funcs
    if not batch:
        options = mstWin.masterShotUI()
        shotOptions["note"] = options.dict["note"]
        shotOptions["shd"] = options.dict["shd"]
        # - -------  add frame range, resolution, FPS?

        note = shotOptions['note']
        if note == "__CANCEL__":
            return "__CANCEL__"

    pm = utils.PathManager(varFolder)
    shotmst = pm.getMaster()
    masterFile = os.path.basename(shotmst)[:-3]

    latestMasterVersion = cFuncs.getLatestVarMaster(
        var, varFolder, fType)  #check if there's a master
    #---------------- HERE: GET two WS FILES. THE SECOND WILL BE THE ONE WE SAVE, THEN EXTERNALLY COPY AND MASTER THE FIRST
    latestWorkshop = cFuncs.getLatestVarWS(
        varFolder)  #check the lastest workshop

    # get the number on the end of te
    if latestMasterVersion and (latestMasterVersion != "Abort"):
        num = int(
            os.path.basename(latestMasterVersion).rstrip(".ma").rpartition(
                "_v")[2])
        incrNum = "{:0>3d}".format(num + 1)

    elif latestMasterVersion == "Abort":
        cmds.warning(
            "masterFuncs.masterShot: There was some kind of issue with the paths to get the latest master for backup"
        )
        return

    elif latestMasterVersion == None:
        incrNum = "001"

    #create file name and full path
    # newPastVersion = "{0}/past_versions/{1}_v{2}.ma".format(varFolder, masterFile, incrNum)
    newPastVersion = cFuncs.fixPath(pm.getNextVersion())

    # does this line up with the ws file structure?
    check = cFuncs.checkCurrentMasterMatch(masterFile, fType)

    if not check:
        #here we bail out if current scene isn't workshop of the scene you're trying to master (from window)
        cmds.confirmDialog(
            t="SCENE MISMATCH",
            m="Your current scene doesn't line up\nwith the asset you've selected\nin the asset window. . . \n\nMake sure you're in a workshop file\nfor the asset you want to master!"
        )
        return "FILE MISMATCH - NO MASTER CREATED!"

    #copy current master to past masters and rename to new num
    currentMaster = "{0}/{1}.ma".format(varFolder, masterFile)
    destination = "{0}".format(newPastVersion)
    currentWS = cmds.file(q=True, sceneName=True)

    #increment ws file from current
    newWSFile = "{0}.ma".format(cFuncs.incrementWS(var, varFolder, fType))
    correctWSnum = "{:0>3d}".format(int(latestWorkshop[-6:-3]))

    # -------------- add more data to the shot master fileInfo
    cFuncs.putFileInfo(fType, correctWSnum, note)

    # increment ws
    cmds.file(rename=newWSFile)
    cmds.file(save=True, type="mayaAscii")

    #do the mastering stuff to the current file, if we bail at any stage, reopen the ws and don't save master
    # depending on type of master we want to do, finish up the mastering process. . . .
    if BG == False and importRefs == True:  # regular master

        print "\n-------------------\nDOING IMPORT MASTER SHOT STUFF HERE!\n-------------------"
        clean = cleanShotScene(fType, BG, importRefs)
        if clean == "Abort":
            print "trying to return you to latest workshop file: {0}".format(
                newWSFile)
            cmds.file(newWSFile, open=True, force=True)
            return (
                "Failed mastering at cleanup phase. Try again after fixing problems"
            )

        cmds.file(rename=currentMaster)
        if os.path.isfile(
                currentMaster
        ):  #check if there is a master file currently. If so, move it to the past versions
            os.rename(currentMaster, destination)
            print "masterFuncs.masterShot:\n------ moving: {0} \n------ to: {1}".format(
                currentMaster, destination)
        cmds.file(save=True, type="mayaAscii")  # save as master
        cmds.file(newFile=True, force=True)

    if BG == False and importRefs == False:  # referenced master
        print "\n-------------------\nDOING REFERENCE MASTER SHOT STUFF HERE!\n-------------------"
        clean = cleanShotScene(fType, BG, importRefs)
        if clean == "Abort":
            print "trying to return you to latest ws file: {0}".format(
                newWSFile)
            cmds.file(newWSFile, open=True, force=True)
            return (
                "Failed mastering at cleanup phase. Try again after fixing problems"
            )

        cmds.file(rename=currentMaster)
        if os.path.isfile(
                currentMaster
        ):  #check if there is a master file currently. If so, move it to the past versions
            os.rename(currentMaster, destination)
            print "masterFuncs.masterShot:\n------ moving: {0} \n------ to: {1}".format(
                currentMaster, destination)
        cmds.file(save=True, type="mayaAscii")  # save as master

        #rename to increment ws
        secondWSFile = "{0}".format(cFuncs.incrementWS(var, varFolder, fType))
        cmds.file(rename=secondWSFile)

        cmds.file(save=True, type="mayaAscii")

    if BG == True and importRefs == True:  # BG master
        # call to function to master shot on current ws
        print "---------- kicking out to BG Master function ------------"
        bgMasterShot(fType, var, varFolder, newWSFile, destination,
                     currentMaster)
        # increment again and open variant ws
        #---------------- maybe DON'T re-increment this here? Just open old ws?
        reincr = "{0}".format(cFuncs.incrementWS(var, varFolder, fType))
        cmds.file(rename=reincr)
        cmds.file(save=True, type="mayaAscii")

    #refresh the info in the shot win
    if cmds.window("shotWin", exists=True):
        import chrlx_pipe.shotWin as shotWin
        shotWin.populateWindow()

    if BG == True:
        return "Mastering in background process: {0}".format(currentMaster)
    if BG == False:
        return "Master created successfully: {0}".format(currentMaster)