def onFileOpenCB(): #make sure the file being loaded is under the current project - otherwise weird things can happen #with the export manager etc... import exportManagerCore if not exportManagerCore.isSceneUnderCurrentProject(): cmd.confirmDialog( m= "WARNING: the current scene isn't under the current project...\n\nthis will most likely cause problems. please exit maya and\nset your project correctly", t="project/scene mismatch", db="OK") #update export manager data... import exportManagerUI exportManager = exportManagerCore.ExportManager() exportManager.update() exportManagerUI.update() #check for the existence of various windows, and reopen them if cmd.window('modelCompiler', ex=True): cmd.deleteUI('modelCompiler') file = Path(cmd.file(q=True, sn=True)) if file.exists: statusDict = P4File(file).getStatus() msgs = [] staleDeps = listOutOfSyncDependencies() if staleDeps: msgs.append( "WARNING: the following files are used by this scene, but aren't up to date with the latest perforce revision:\n\n%s\n\nyou can sync all dependencies from the perforce menu in maya:\nPerforce -> Sync Maya Dependencies" % '\n'.join(staleDeps)) #check to see if the file is open for edit by someone else, and warn the user otherOpens = [] try: otherOpens = statusDict['otherOpen'] except KeyError: pass except TypeError: pass if otherOpens: msgs.append( "WARNING: this file is open for edit by:\n%s\n\nif you plan of making changes, make sure you check when them first before putting in too much work" % '\n'.join(otherOpens)) if msgs: cmd.confirmDialog( m='\n------------------------------\n\n'.join(msgs), b='OK', db='OK')
def onFileOpenCB(): #make sure the file being loaded is under the current project - otherwise weird things can happen #with the export manager etc... import exportManagerCore if not exportManagerCore.isSceneUnderCurrentProject(): cmd.confirmDialog( m="WARNING: the current scene isn't under the current project...\n\nthis will most likely cause problems. please exit maya and\nset your project correctly", t="project/scene mismatch", db="OK" ) #update export manager data... import exportManagerUI exportManager = exportManagerCore.ExportManager() exportManager.update() exportManagerUI.update() #check for the existence of various windows, and reopen them if cmd.window( 'modelCompiler', ex=True ): cmd.deleteUI( 'modelCompiler' ) file = Path( cmd.file( q=True, sn=True ) ) if file.exists: statusDict = P4File( file ).getStatus() msgs = [] staleDeps = listOutOfSyncDependencies() if staleDeps: msgs.append( "WARNING: the following files are used by this scene, but aren't up to date with the latest perforce revision:\n\n%s\n\nyou can sync all dependencies from the perforce menu in maya:\nPerforce -> Sync Maya Dependencies" % '\n'.join( staleDeps ) ) #check to see if the file is open for edit by someone else, and warn the user otherOpens = [] try: otherOpens = statusDict[ 'otherOpen' ] except KeyError: pass except TypeError: pass if otherOpens: msgs.append( "WARNING: this file is open for edit by:\n%s\n\nif you plan of making changes, make sure you check when them first before putting in too much work" % '\n'.join( otherOpens ) ) if msgs: cmd.confirmDialog( m='\n------------------------------\n\n'.join( msgs ), b='OK', db='OK' )