Exemple #1
0
 def checkForAnimationSaved(self, clearDeferredQueue=False, *args):
     if clearDeferredQueue: self.deferredQueue      = []
     
     sceneId         = aToolsMod.getSceneId()
     idFolder        = "%s%s%s"%(self.baseFolderName, os.sep,  sceneId)
     latestFolder    = "%s%s%s"%(idFolder, os.sep, self.baseLatestFolderName)  
     infoFile        = "%s%s%s%s%s.info"%(G.USER_FOLDER, os.sep, latestFolder, os.sep, self.infoDataFileName)
     mayaFile        = cmds.file(query=True, sceneName=True)
     
     if not os.path.isfile(infoFile) or not os.path.isfile(mayaFile): return
     
     mayaFileModTime = os.path.getmtime(mayaFile) 
     infoFileModTime = os.path.getmtime(infoFile)
     
     if mayaFileModTime < infoFileModTime:   
         
         infoData    = aToolsMod.loadFileWithUser(latestFolder, self.infoDataFileName, ext="info")
         
         if not infoData: return
         
         height              = 170
         completed           = infoData["completed"]
         mayaFileModTimeStr  = time.ctime(mayaFileModTime)
         infoFileModTimeStr  = time.ctime(infoFileModTime)            
         message             = "This Maya file:\n%s\n\n"%(mayaFileModTimeStr)
         message             += "Latest Animation Crash Recovery file:\n%s"%(infoFileModTimeStr)
         
         if not completed:   
             message += "\n\n*Some animation may not be loaded.\nAnimation Crash Recovery did not finish saving before Maya crashed."
             height  += 40
             
         self.warningForLoading(message, height)
Exemple #2
0
    def optionBoxWindow(self, *args):
        
        sceneId         = aToolsMod.getSceneId()
        idFolder        = "%s%s%s"%(self.baseFolderName, os.sep, sceneId)    
        bkpFolder       = "%s%s%s"%(idFolder, os.sep, self.baseBackupFolderName)         
        infoData        = aToolsMod.loadFileWithUser(bkpFolder, self.infoDataFileName, ext="info")
        infoDataFile    = "%s%s%s%s%s.info"%(G.USER_FOLDER, os.sep, bkpFolder, os.sep, self.infoDataFileName)
        modDate         = os.path.getmtime(infoDataFile) if os.path.isfile(infoDataFile) else None
        
        
        if not infoData or not modDate: 
            cmds.warning("There is no crash file to restore.")
            return
        
        
        def loadWindow():
            
            mayaFileName    = infoData["mayaFileName"]
            message         = "%s\n%s\n\nWarning: Loading crash files after editing your Maya file can lead to unpredictable results."%(mayaFileName, time.ctime(modDate))
            
            formLayout      = cmds.setParent(query=True)        
            icon            = cmds.image(image= uiMod.getImagePath("ACR_white_bright")) 
            titleText       = cmds.text(label="Do you want to load?", font="boldLabelFont", align="left")  
            messageText     = cmds.text(label=message, align="left")
            buttonLoad      = cmds.button(label='Load', command='cmds.layoutDialog(dismiss="load")')
            buttonLoadSel   = cmds.button(label='Load On Selection', command='cmds.layoutDialog(dismiss="load_selection")', w=110)
           
            cmds.formLayout (formLayout, edit=True, width=300, height=170,
                            attachPosition   = [
                                             (icon, 'left', 10, 0), 
                                             (icon, 'top', 10, 0),  
                                             (titleText, 'top', 10, 0), 
                                             (messageText, 'left', 10, 0), 
                                             (messageText, 'top', 0, 30),
                                             (buttonLoad, 'left', 10, 0),
                                             (buttonLoad, 'bottom', 10, 100),
                                             (buttonLoadSel, 'bottom', 10, 100)
                                             ],
                            attachForm       = [
                                             (buttonLoad, 'left', 10),
                                             (buttonLoadSel, 'right', 10)
                                             ],
                            attachControl    = [
                                             (titleText, 'left', 10, icon),
                                             (buttonLoad, 'right', 5, buttonLoadSel)
                                             ])

            
        def window(dismiss):
         
            if dismiss == "dismiss": return

            onlySelectedNodes   = True if dismiss == "load_selection" else False
            
            self.loadData(onlySelectedNodes, self.baseBackupFolderName)  
                         
        
        window(cmds.layoutDialog(title="aTools Animation Crash Recovery", ui=loadWindow)) 
Exemple #3
0
 def loadInfoData(self):
     sceneId     = aToolsMod.getSceneId()
     infoData    = aToolsMod.loadFileWithUser("%s%s%s%s%s"%(self.baseFolderName, os.sep,  sceneId, os.sep, self.baseLatestFolderName), self.infoDataFileName, ext="info")
     
     if not infoData: return
     
     currFrame   = infoData["currFrame"]
     currSel     = infoData["currSel"]
             
     if currFrame:           cmds.currentTime(currFrame)
     if len(currSel) > 0:    cmds.select(currSel, replace=True)
Exemple #4
0
    def getDataFromFiles(self, animAttr, folder, infoFiles, fileModTime, ext, progressInfo, onlySelectedNodes):
        currSel             = animMod.getObjsSel()
        data                = {"data":[], "modTime":None}
        infoFileModTimeList = []
        startChrono, firstStep, thisStep, totalSteps, estimatedTime, status = progressInfo
        initialStep         = thisStep
        
        for n, loopFile in enumerate(infoFiles): 
            if cmds.progressBar(G.progBar, query=True, isCancelled=True ):  
                utilMod.setProgressBar(endProgress=True)
                return
            
            thisStep        = n+initialStep
            startChrono     = utilMod.chronoStart(startChrono, firstStep, thisStep, totalSteps, estimatedTime, status)  
                      
            infoFileStr     = loopFile.replace(":", "_aTools_")[0:-(len(ext)+1)]
            infoFilePath    = aToolsMod.getSaveFilePath("%s%s%s"%(folder, os.sep, infoFileStr), ext=ext)
            infoFileModTimeList.append(os.path.getmtime(infoFilePath))
            
            if infoFileModTimeList[-1] > fileModTime: #load only what is newer
                object          = loopFile.replace("_aTools_", ":")[0:-(len(ext)+1)]
                value           = aToolsMod.loadFileWithUser(folder, infoFileStr, ext=ext)
            
                if onlySelectedNodes:
                    if animAttr == "anim":
                        obj = value["objects"][0]
                    else:  
                        obj = object.split(".")[0]

                    if obj not in currSel: continue           
            
            
                data["data"].append({"_modTime":infoFileModTimeList[-1],"object":object, "value":value})
            
            estimatedTime = utilMod.chronoEnd(startChrono, firstStep, thisStep, totalSteps)
            
        #file mod date
        data["data"].sort() #sort newer files last
        if len(infoFileModTimeList) > 0:
            data["modTime"] = max(infoFileModTimeList)
        
        progressInfo = [startChrono, firstStep, thisStep, totalSteps, estimatedTime, status]
        #blend animation data=================
        
        return [data, progressInfo]
Exemple #5
0
 def loadCrashLog(self):        
     
     return aToolsMod.loadFileWithUser("%s"%(self.baseFolderName), "crashLog", ext="info")