def submitRenderUI(): stf_window = qtBase.BaseWindow(qtBase.GetMayaWindow(),'submitToFarm.ui') stf_window._windowTitle = 'Submit to Farm' stf_window._windowName = 'SubmitToFarm' stf_window.pathModify = 'pipelime/' stf_window.BuildUI() stf_window.show(dockable=True) #hide config panel stf_window.mainWidget.configPanel.setVisible(False) #connect buttons stf_window.mainWidget.submitButton.clicked.connect(submitButton) stf_window.mainWidget.pushButton_globals.clicked.connect(globalDict) stf_window.mainWidget.pushButton_project.clicked.connect(projectDict) stf_window.mainWidget.pushButton_user.clicked.connect(localDict) stf_window.mainWidget.pushButton_render.clicked.connect(selectRenderExe) stf_window.mainWidget.pushButton_submitExe.clicked.connect(selectSubmitExe) #icon on button try: buttonIcon = QtGui.QIcon("%s/icons/%s.png"%(qtBase.self_path(), "gear")) stf_window.mainWidget.pushButton_settings.setIcon(buttonIcon) except: pass #merge all dictionaries into one comboDict = {} comboDict = mergeDictionaries(comboDict,IO.loadDictionary('%s/config/globalPrefs.json'%qtBase.self_path())) comboDict = mergeDictionaries(comboDict,IO.loadDictionary('%s/data/projectPrefs.json'%getProj.getProject())) comboDict = mergeDictionaries(comboDict,IO.loadDictionary('%s/localPrefs.json'%qtBase.local_path())) rangeFromTimeline = '%s-%s'%(sceneVar.getStartFrame(),sceneVar.getEndFrame()) comboDict = mergeDictionaries(comboDict,{"lineEdit_range": {"value":rangeFromTimeline}}) versionlessSceneName = ''.join([c for c in getProj.sceneName() if c not in "1234567890"]) comboDict = mergeDictionaries(comboDict,IO.loadDictionary('%s/.data/%s.json'%(getProj.sceneFolder(),versionlessSceneName))) setOptions(comboDict,stf_window) return stf_window
def prefConfigUI(): window = qtBase.BaseWindow(qtBase.GetMayaWindow(), 'lm_projectConfig.ui') window._windowTitle = 'Configure Project' window._windowName = 'configureProject' window.pathModify = 'pipelime/' window.BuildUI() window.show(dockable=True) #connect buttons window.mainWidget.pushButton_accept.clicked.connect(submitButton) #merge all dictionaries into one comboDict = { "userName": { "value": "" }, "userInitials": { "value": "" }, "userSlackID": { "value": "@" } } #comboDict = mergeDictionaries(comboDict,IO.loadDictionary('C:/Users/Admin/Documents/Toolbox/config/globalPrefs.json')) comboDict = mergeDictionaries( comboDict, IO.loadDictionary('%s/localPrefs.json' % qtBase.local_path())) projectDict = IO.loadDictionary('%s/../.projectData/projectPrefs.json' % getProj.getProject()) print projectDict projectLines = [] for key in projectDict: try: projectLines.append([key, projectDict[key]["value"]]) except: pass lines = [] for key in comboDict: try: lines.append([key, comboDict[key]["value"]]) except: pass #layers = sceneVar.getRenderLayers() global prefWidget prefWidget = LayerWidget(lines, window.mainWidget.verticalLayout_user) global projectPrefsWidget prefWidget = LayerWidget(projectLines, window.mainWidget.verticalLayout_project) global globalPrefsWidget prefWidget = LayerWidget(lines, window.mainWidget.verticalLayout_global) return window
def openAssetManagertWindow(): global assetManagerUIWindow global projectsDictGlobal assetManagerUIWindow = assetManagerUI() #set project dropdown to current project currentProject = cmds.workspace(fullName=True) projectsDict = IO.loadDictionary('%s/projects.json' % qtBase.local_path()) projectsDictGlobal = projectsDict print currentProject print projectsDict foundProject = 0 for d in projectsDict: print d print projectsDict[d]['projectPath'] if currentProject == projectsDict[d]['projectPath']: print 'key = %s' % d assetManagerUIWindow.mainWidget.project_comboBox.setCurrentText(d) setProject() foundProject = 1 if foundProject == 0: #print try: setProject() except: pass
def setProject(): projectsDict = IO.loadDictionary('%s/projects.json' % qtBase.local_path()) print projectsDict print 'foobar' key = assetManagerUIWindow.mainWidget.project_comboBox.currentText() projectPath = projectsDict[key]["projectPath"] assetTypeFolders = [] path = '%s/scenes/REF/' % projectPath files = os.listdir(path) for name in files: if os.path.isdir(os.path.join(os.path.abspath(path), name)): #remove hidden folders if name[0] != '.': assetTypeFolders.append(name) #populate listWidget with folders assetManagerUIWindow.mainWidget.listWidget_assetType.clear() assetManagerUIWindow.mainWidget.listWidget_assetType.addItems( assetTypeFolders) #select first item in list try: items = [] for index in xrange( assetManagerUIWindow.mainWidget.listWidget_assetType.count()): items.append( assetManagerUIWindow.mainWidget.listWidget_assetType.item( index)) items[0].setSelected(True) assetManagerUIWindow.mainWidget.listWidget_assetType.setCurrentItem( items[0]) setType() except: pass
def orderByModified(dirpath): # get all entries in the directory w/ stats entries = (os.path.join(dirpath, fn) for fn in os.listdir(dirpath)) entries = ((os.stat(path), path) for path in entries) # leave only regular files, insert creation date entries = ((stat[ST_MTIME], path) for stat, path in entries if S_ISREG(stat[ST_MODE])) recentFiles = [] for cdate, path in sorted(entries): #print time.ctime(cdate), os.path.basename(path) dateModified = time.strftime('%Y/%m/%d - %I:%M %p', time.localtime(os.path.getmtime(path))) fileDictPath = '%s/.data/%s.json' % (path.rsplit( '\\', 1)[0], path.split('\\')[-1].rsplit('.', 1)[0]) fileDict = IO.loadDictionary(fileDictPath) artistName = '' try: artistName = fileDict["user"]["value"] except: pass recentFiles.append([os.path.basename(path), artistName, dateModified]) return recentFiles
def incrementSceneFile(): localPrefDict = IO.loadDictionary('%s/localPrefs.json' % qtBase.local_path()) try: userInitials = localPrefDict["userInitials"]["value"].strip('\'') except: userInitials = '' incSave.IncrementCurrentFile(initials=userInitials) writeDataAfterSave()
def assetManagerUI(): window = qtBase.BaseWindow(qtBase.GetMayaWindow(), 'lm_assetManager.ui') window._windowTitle = 'Asset Manager' window._windowName = 'assetManager' window.pathModify = 'pipelime/' window.BuildUI() window.show(dockable=True) projectsDict = IO.loadDictionary('%s/projects.json' % qtBase.local_path()) projectLines = [] for key in projectsDict: try: projectLines.append(key) except: pass window.mainWidget.project_comboBox.addItems(projectLines) window.mainWidget.project_comboBox.currentTextChanged.connect(setProject) window.mainWidget.listWidget_assetType.currentTextChanged.connect(setType) #add project button window.mainWidget.pushButton_addProject.clicked.connect(selectFolder) #remove project button window.mainWidget.pushButton_removeProject.clicked.connect(removeProject) #change asset selection window.mainWidget.listWidget_assets.currentTextChanged.connect(setAsset) window.mainWidget.listWidget_assets.doubleClicked.connect(doubleClicked) #window.mainWidget.listWidget_assets.itemSelectionChanged.connect(listChanged) #reference button window.mainWidget.pushButton_reference.clicked.connect( lambda: referenceAsset( window.mainWidget.listWidget_assets.selectedItems(), 0)) #import button window.mainWidget.pushButton_import.clicked.connect(lambda: referenceAsset( window.mainWidget.listWidget_assets.selectedItems(), 1)) #new button window.mainWidget.pushButton_new.clicked.connect(newAsset) #edit button window.mainWidget.pushButton_edit.clicked.connect(lambda: editAsset( window.mainWidget.listWidget_assets.currentItem().text())) #thumbnail button window.mainWidget.pushButton_thumb.clicked.connect(lambda: takeScreenshot( window.mainWidget.listWidget_assets.currentItem().text())) #save button window.mainWidget.pushButton_save.clicked.connect(saveSceneFile) #increment button window.mainWidget.pushButton_increment.clicked.connect(incrementSceneFile) #publish button window.mainWidget.pushButton_publish.clicked.connect(publishModel) #set project in menu return window
def removeProject(): #read curent project from dropdown menu currentProject = assetManagerUIWindow.mainWidget.project_comboBox.currentText( ) #load project dictionary projectDict = IO.loadDictionary('%s/projects.json' % qtBase.local_path()) #remove current project from dictionary del projectDict[currentProject] #write out to json file with open('%s/projects.json' % qtBase.local_path(), mode='w') as feedsjson: json.dump(projectDict, feedsjson, indent=4, sort_keys=True) #remove text from dropdown menu assetManagerUIWindow.mainWidget.project_comboBox.removeItem( assetManagerUIWindow.mainWidget.project_comboBox.currentIndex())
def selectFolder(): filename = QtWidgets.QFileDialog.getExistingDirectory() projectName = filename.split('/')[-2] projectPath = filename projectData = [] projectData.append([projectName, 'projectPath', projectPath]) IO.writePrefsToFile(projectData, '%s/projects.json' % qtBase.local_path()) assetManagerUIWindow.mainWidget.project_comboBox.addItems([projectName]) assetManagerUIWindow.mainWidget.project_comboBox.setCurrentText( projectName) global projectsDictGlobal projectsDictGlobal = IO.loadDictionary('%s/projects.json' % qtBase.local_path())
def writeDataAfterSave(): metaData = [] localPrefDict = IO.loadDictionary('%s/localPrefs.json' % qtBase.local_path()) metaData.append([ 'user', 'value', '%s' % localPrefDict["userName"]["value"].strip('\'') ]) metaData.append([ 'note', 'value', '%s' % assetManagerUIWindow.mainWidget.textEdit_note.toPlainText() ]) IO.writePrefsToFile( metaData, '%s/.data/%s.json' % (getProj.sceneFolder(), getProj.sceneName()))
def publishModel(): IO_publishModel(0) metaData = [] localPrefDict = IO.loadDictionary('%s/localPrefs.json' % qtBase.local_path()) metaData.append([ 'user', 'value', '%s' % localPrefDict["userName"]["value"].strip('\'') ]) metaData.append([ 'note', 'value', '%s' % assetManagerUIWindow.mainWidget.textEdit_note.toPlainText() ]) folderName = getProj.sceneFolder().rsplit('/', 1)[1] IO.writePrefsToFile( metaData, '%s/.data/%s_REF.json' % (getProj.sceneFolder(), folderName))
def lm_projectWindow(): window = qtBase.BaseWindow(qtBase.GetMayaWindow(),'lm_projectWindow.ui') window._windowTitle = 'Create New Project' window._windowName = 'createNewProject' #self.uiFilePath = 'C:/Users/Admin/Documents/Toolbox' window.pathModify = 'pipelime/' window.BuildUI() window.show(dockable=True) #connect buttons window.mainWidget.variant_pushButton.clicked.connect(addButton) window.mainWidget.create_pushButton.clicked.connect(createButton) folderStructureDict = loadSave.loadDictionary('%s/pipelime/lm_folderStructure.json'%qtBase.self_path()) rootFolders = folderStructureDict["root"] window.mainWidget.comboBox_root.clear() window.mainWidget.comboBox_root.addItems(rootFolders) resolutions = folderStructureDict["settings"]["resolution"] window.mainWidget.comboBox_resolution.clear() window.mainWidget.comboBox_resolution.addItems(resolutions.keys()) window.mainWidget.comboBox_resolution.currentTextChanged.connect(resolutionChange) return window
def newAsset(): setProjectPth() newAssetType = assetManagerUIWindow.mainWidget.lineEdit_newAssetType.text() newAssetName = assetManagerUIWindow.mainWidget.lineEdit_newAssetName.text() if newAssetName: if not newAssetType: newAssetType = assetManagerUIWindow.mainWidget.listWidget_assetType.currentItem( ).text() project = assetManagerUIWindow.mainWidget.project_comboBox.currentText( ) assetPath = '%s/scenes/REF/%s/%s' % ( projectsDictGlobal[project]["projectPath"], newAssetType, newAssetName) itemsText = [] items = [] for index in xrange( assetManagerUIWindow.mainWidget.listWidget_assetType.count()): items.append( assetManagerUIWindow.mainWidget.listWidget_assetType.item( index)) itemsText.append( assetManagerUIWindow.mainWidget.listWidget_assetType.item( index).text()) if newAssetType not in itemsText: #add item to type list itm = QtWidgets.QListWidgetItem(newAssetType) assetManagerUIWindow.mainWidget.listWidget_assetType.addItem(itm) assetManagerUIWindow.mainWidget.listWidget_assets.clear() if not os.path.exists(assetPath): os.makedirs(assetPath) else: for i in items: if newAssetType == i.text(): itm = i #setType() itm.setSelected(True) #add item to asset list try: dirname = os.path.dirname(__file__) except: print 'running in test environment' dirname = 'C:/Users/Admin/Documents/Toolbox' itm = QtWidgets.QListWidgetItem( QtGui.QIcon('%s/icons/lightRed.png' % (dirname)), newAssetName) assetManagerUIWindow.mainWidget.listWidget_assets.addItem(itm) for index in xrange( assetManagerUIWindow.mainWidget.listWidget_assets.count()): (assetManagerUIWindow.mainWidget.listWidget_assets.item(index) ).setSelected(False) itm.setSelected(True) #create folder and file if not os.path.exists(assetPath): os.makedirs(assetPath) #create new file cmds.file(newFile=True, force=True) cmds.file(rename='%s/%s_v001_cl.mb' % (assetPath, newAssetName)) #set settings from project config file try: configFolder = '%s../.projectData' % getProj.getProject() projectsDict = IO.loadDictionary('%s/projectPrefs.json' % configFolder) cmds.setAttr("defaultResolution.width", int(projectsDict["resolutionW"]["value"])) cmds.setAttr("defaultResolution.height", int(projectsDict["resolutionH"]["value"])) fps = '%sfps' % (projectsDict["frameRate"]["value"]) cmds.currentUnit(time=fps) except: pass
def setProjectPth(): projectsDict = IO.loadDictionary('%s/projects.json' % qtBase.local_path()) key = assetManagerUIWindow.mainWidget.project_comboBox.currentText() cmds.workspace(projectsDict[key]['projectPath'], openWorkspace=True)
def createButton(): folderNames = [] varients = [] for v in bwidget.layerWidgets: try: if not v.isHidden(): varients.append(v.variant_lineEdit.text()) except: pass if not varients: varients = [''] parentFolder = lm_projectWin.mainWidget.comboBox_root.currentText() clientName = lm_projectWin.mainWidget.lineEdit_client.text() projectName = lm_projectWin.mainWidget.lineEdit_project.text() projectRoot = '%s/untitledProject'%(parentFolder) if clientName and projectName: projectRoot = '%s/%s_%s'%(parentFolder,clientName,projectName) elif clientName: projectRoot = '%s/%s'%(parentFolder,clientName) elif projectName: projectRoot = '%s/%s'%(parentFolder,projectName) folderStructureDict = loadSave.loadDictionary('%s/pipelime/lm_folderStructure.json'%qtBase.self_path()) #create general folders for i in folderStructureDict["general"]["folders"]: folderNames.append('%s/%s'%(projectRoot,i)) #perform options checkBoxes = [[lm_projectWin.mainWidget.checkBox_3D,'3D'],[lm_projectWin.mainWidget.checkBox_anim,'anim'],[lm_projectWin.mainWidget.checkBox_FX,'FX'],[lm_projectWin.mainWidget.checkBox_track,'tracking'],[lm_projectWin.mainWidget.checkBox_2D,'2D Animation'],[lm_projectWin.mainWidget.checkBox_render,'render'],[lm_projectWin.mainWidget.checkBox_comp,'Comp'],[lm_projectWin.mainWidget.checkBox_edit,'Edit'],[lm_projectWin.mainWidget.checkBox_live,'Live action'],[lm_projectWin.mainWidget.checkBox_board,'Storyboard'],[lm_projectWin.mainWidget.checkBox_matte,'Matte Painting'],[lm_projectWin.mainWidget.checkBox_matte,'Audio']] for c in checkBoxes: if c[0].isChecked() == 1: #create folders for i in folderStructureDict["options"][c[1]]["folders"]: if '<var>' not in i: folderNames.append('%s/%s'%(projectRoot,i)) else: for v in varients: vi = i.replace('<var>', v) folderNames.append('%s/%s'%(projectRoot,vi)) #make all of the folders makeFolders(folderNames) for c in checkBoxes: if c[0].isChecked() == 1: #copy files try: for i in folderStructureDict["options"][c[1]]["files"]: sourcePath = '%s/pipelime/files'%qtBase.self_path() sourceFile = '%s/%s'%(sourcePath,i["source"]) destFile = '%s/%s/%s'%(projectRoot,i["dest"],i["source"]) sourceFile = os.path.realpath(sourceFile) destFile = os.path.realpath(destFile) shutil.copyfile(sourceFile, destFile) except: pass #set prefs for project projectDict('%s/.projectData'%projectRoot) #open window path=os.path.realpath(projectRoot) os.startfile(path)
def setAsset(): try: assetName = assetManagerUIWindow.mainWidget.listWidget_assets.currentItem( ).text() except: pass try: assetType = assetManagerUIWindow.mainWidget.listWidget_assetType.currentItem( ).text() except: pass project = assetManagerUIWindow.mainWidget.project_comboBox.currentText() try: thumbPath = '%s/scenes/REF/%s/%s/.data/%s_thumb.jpg' % ( projectsDictGlobal[project]["projectPath"], assetType, assetName, assetName) except: pass #find and display date try: refPath = '%s/scenes/REF/%s/%s_REF.mb' % ( projectsDictGlobal[project]["projectPath"], assetType, assetName) dateModified = time.strftime('%d/%m/%Y', time.localtime(os.path.getmtime(refPath))) currentDate = time.strftime("%d/%m/%Y", time.localtime()) if dateModified == currentDate: dateModified = 'Today' timeModified = time.strftime('%a %I:%M %p', time.localtime(os.path.getmtime(refPath))) assetManagerUIWindow.mainWidget.label_date.setText( '%s - %s' % (dateModified, timeModified)) except: assetManagerUIWindow.mainWidget.label_date.setText('') #find and display username try: namePath = '%s/scenes/REF/%s/%s/.data/%s_REF.json' % ( projectsDictGlobal[project]["projectPath"], assetType, assetName, assetName) assetDict = IO.loadDictionary(namePath) assetManagerUIWindow.mainWidget.label_userName.setText( assetDict["user"]["value"]) except: assetManagerUIWindow.mainWidget.label_userName.setText('') #find and display note try: namePath = '%s/scenes/REF/%s/%s/.data/%s_REF.json' % ( projectsDictGlobal[project]["projectPath"], assetType, assetName, assetName) assetDict = IO.loadDictionary(namePath) assetManagerUIWindow.mainWidget.textEdit_note.setText( assetDict["note"]["value"]) except: assetManagerUIWindow.mainWidget.textEdit_note.setText('') try: buttonIcon = QtGui.QIcon(thumbPath) assetManagerUIWindow.mainWidget.pushButton_thumb.setIcon(buttonIcon) assetManagerUIWindow.mainWidget.pushButton_thumb.setText("") except: pass assetManagerUIWindow.mainWidget.tableWidget_assetVersions.setVisible(0) try: setVersion(assetName) except: pass
def resolutionChange(text): folderStructureDict = loadSave.loadDictionary('%s/pipelime/lm_folderStructure.json'%qtBase.self_path()) lm_projectWin.mainWidget.lineEdit_resW.setText(folderStructureDict["settings"]["resolution"][text][0]) lm_projectWin.mainWidget.lineEdit_resH.setText(folderStructureDict["settings"]["resolution"][text][1])