def open_selected(*args): proj = ai.AssetInfo() # if no file then warn and skip selFile = cmds.textScrollList(widgets["filesTSL"], q=True, si=True)[0] if selFile == "No Files": cmds.warning("No files available to open!") return () # construct the paths tab, phase, assetPath, assetFiles = [None, None, None, None] selTab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True) if selTab != "STGS": tab, phase, assetPath, assetFiles = get_asset_info(proj) else: tab, phase, assetPath, assetFiles = get_stage_info(proj) selIndex = cmds.textScrollList(widgets["filesTSL"], q=True, sii=True)[0] filePath = os.path.join(assetPath, assetFiles[selIndex - 1]) # check mods, if so then. . changed = cmds.file(q=True, modified=True) svState = True if changed: svState = save_current_dialog() if svState: of.run(filePath) else: return ()
def load_asset_info(counter=None, *args): """ gets the info for the assets in the project ARGS: counter (string) """ clear_asset_lists() proj = ai.AssetInfo() assetNames = proj.get_asset_name_list() for asset in assetNames[0]: cmds.textScrollList(widgets["charTSL"], e=True, a=asset, sc=partial(populate_files, proj)) for asset in assetNames[1]: cmds.textScrollList(widgets["propTSL"], e=True, a=asset, sc=partial(populate_files, proj)) for asset in assetNames[2]: cmds.textScrollList(widgets["setTSL"], e=True, a=asset, sc=partial(populate_files, proj)) for asset in assetNames[3]: cmds.textScrollList(widgets["stageTSL"], e=True, a=asset, sc=partial(populate_files, proj)) select_initial(proj, counter)
def get_stage_info(proj, *args): """ gets info from state of the ui ARGS: proj (AssetInfo object) - the info for the current project files Returns: tab (string) - which tab is selected ("CHARS", "SETS", "PROPS", "STGS") phase (string) - which phase we're in ("Modeling", "Rigging", etc) assetPath (string) - the path to the asset folder ("x://.../Stage/FireFlyStage") based on above assetFiles (list) - list of asset file paths based on above """ proj = ai.AssetInfo() asset = None assetFiles = None assetR = cmds.textScrollList(widgets["stageTSL"], q=True, si=True) if not assetR: assetR = cmds.textScrollList(widgets["stageTSL"], q=True, sii=0) asset = assetR[0] assetPath = os.path.join(proj.stagePath, asset) tab = "STGS" phase = "Animation" proj.get_stage_contents(assetPath) assetPath = proj.stageAnmPath assetFiles = proj.stageAnmWorkFiles return (tab, phase, assetPath, assetFiles)
def load_asset_info(*args): clear_asset_lists() proj = ai.AssetInfo() assetNames = proj.get_asset_name_list() for asset in assetNames[0]: cmds.textScrollList(widgets["charTSL"], e=True, a=asset, sc=populate_files) for asset in assetNames[1]: cmds.textScrollList(widgets["propTSL"], e=True, a=asset, sc=populate_files) for asset in assetNames[2]: cmds.textScrollList(widgets["setTSL"], e=True, a=asset, sc=populate_files) for asset in assetNames[3]: cmds.textScrollList(widgets["stageTSL"], e=True, a=asset, sc=populate_files) select_initial()
def save_as_new(selectionBased=False, *args): proj = ai.AssetInfo() # construct the paths filePath = None selTab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True) if selTab != "STGS": tab, phase, assetPath, assetFiles = get_asset_info(proj) else: tab, phase, assetPath, assetFiles = get_stage_info(proj) selItem = None if cmds.textScrollList(widgets["filesTSL"], q=True, sii=True): selIndex = cmds.textScrollList(widgets["filesTSL"], q=True, sii=True)[0] selItem = cmds.textScrollList(widgets["filesTSL"], q=True, si=True)[0] if not selItem or selItem == "No Files": if tab == "CHARS": asset = cmds.textScrollList(widgets["charTSL"], q=True, si=True)[0] if tab == "PROPS": asset = cmds.textScrollList(widgets["propTSL"], q=True, si=True)[0] if tab == "SETS": asset = cmds.textScrollList(widgets["setTSL"], q=True, si=True)[0] if tab == "STGS": asset = cmds.textScrollList(widgets["stageTSL"], q=True, si=True)[0] filename = "{0}_main_{1}_Work_v0001.mb".format(asset, phase) filePath = uf.fix_path(os.path.join(assetPath, filename)) # or use the path from selections else: filePath = uf.fix_path(os.path.join(assetPath, assetFiles[selIndex - 1])) savenewdata = snw.SaveNewAssetUI(filePath, selectionBased)
def change_stage_tab(*args): """ when tab changes, just select first in the list """ proj = ai.AssetInfo() currTab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True) currScene = cmds.file(q=True, sn=True) if currTab == "CHARS": tsl = "char" cmds.optionMenu(widgets["phaseOM"], e=True, en=True) if currTab == "PROPS": tsl = "prop" cmds.optionMenu(widgets["phaseOM"], e=True, en=True) if currTab == "SETS": tsl = "set" cmds.optionMenu(widgets["phaseOM"], e=True, en=True) if currTab == "STGS": tsl = "stage" cmds.optionMenu(widgets["phaseOM"], e=True, en=False, v="Animation") if currScene: # try to find in the current scene pp = uf.PathParser(currScene) if pp.compatible: if pp.name in cmds.textScrollList(widgets["{0}TSL".format(tsl)], q=True, allItems=True): cmds.textScrollList(widgets["{0}TSL".format(tsl)], e=True, si=pp.name) else: cmds.textScrollList(widgets["{0}TSL".format(tsl)], e=True, sii=1) else: cmds.textScrollList(widgets["{0}TSL".format(tsl)], e=True, sii=1) else: cmds.textScrollList(widgets["{0}TSL".format(tsl)], e=True, sii=1) populate_files(proj)
def clear_all_object_info(*args): proj = ai.AssetInfo() refObjList = [] namespaceList = [] widgets = {} ReferenceObject.existingRefList = [] ReferenceObject.currentObjList = [] ReferenceObject.pendingObjList = [] ReferenceObject.allObjectList = []
def load_asset_info(*args): clear_asset_lists() proj = ai.AssetInfo() assetNames = proj.get_asset_name_list() for asset in assetNames[0]: cmds.textScrollList(widgets["charTSL"], e=True, a=asset)#, sc=temp) for asset in assetNames[1]: cmds.textScrollList(widgets["propTSL"], e=True, a=asset)#, sc=temp) for asset in assetNames[2]: cmds.textScrollList(widgets["setTSL"], e=True, a=asset)#, sc=temp) select_the_first()
def __init__(self, filePath=None, selectionBased=False, *args): self.dict = {} self.projEnvPath = os.environ["MAYA_PROJECT_PATH"] self.selBased = selectionBased self.filePath = filePath print "filePath: ", self.filePath self.proj = ai.AssetInfo() self.pp = uf.PathParser(filePath) if not self.pp.compatible: # dummy check that the folders exist files = self.proj.get_asset_contents(self.proj.charsPath[0]) self.filepath = "{0}{1}".format(self.proj.charsPath[0], files[0]) self.assetList = self.proj.get_asset_name_list() self.saveAs_UI()
def get_asset_info(proj, *args): """ gets info from state of the ui ARGS: proj (AssetInfo object) - the info for the current set project Returns: tab (string) - which tab is selected ("CHARS", "SETS", "PROPS") phase (string) - which phase we're in ("Modeling", "Rigging", etc) assetPath (string) - the path to the asset folder ("x://.../Assets/Character/Fish") based on above assetFiles (list) - list of asset file paths based on above """ proj = ai.AssetInfo() asset = None assetFiles = None tab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True) phase = cmds.optionMenu(widgets["phaseOM"], q=True, value=True) if tab == "CHARS": asset = cmds.textScrollList(widgets["charTSL"], q=True, si=True)[0] assetPath = os.path.join(proj.charPath, asset) if tab == "PROPS": asset = cmds.textScrollList(widgets["propTSL"], q=True, si=True)[0] assetPath = os.path.join(proj.propPath, asset) if tab == "SETS": asset = cmds.textScrollList(widgets["setTSL"], q=True, si=True)[0] assetPath = os.path.join(proj.setPath, asset) proj.get_asset_contents(assetPath) if phase == "Modeling": assetPath = proj.mdlPath assetFiles = sorted(proj.mdlWorkFiles) if phase == "Rigging": assetPath = proj.rigPath assetFiles = sorted(proj.rigWorkFiles) if phase == "Animation": assetPath = proj.anmPath assetFiles = sorted(proj.anmWorkFiles) if phase == "Lighting": assetPath = proj.lgtPath assetFiles = sorted(proj.lgtWorkFiles) if phase == "Texturing": assetPath = proj.txtPath assetFiles = sorted(proj.txtWorkFiles) return (tab, phase, assetPath, assetFiles)
def populate_files(proj, *args): """ clears the file list, then populates based on the phase and the selected asset in the asset TSL """ proj = ai.AssetInfo() clear_file_list() selTab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True) tab, phase, assetPath, assetFiles = [None, None, None, None] if selTab != "STGS": tab, phase, assetPath, assetFiles = get_asset_info(proj) else: tab, phase, assetPath, assetFiles = get_stage_info(proj) if assetFiles: for file in assetFiles: a = cmds.textScrollList(widgets["filesTSL"], e=True, a=os.path.basename(file)) else: cmds.textScrollList(widgets["filesTSL"], e=True, a="No Files") # add popmenu to the list object to go to explorer cmds.popupMenu(p=widgets["filesTSL"]) cmds.menuItem(l="Open Folder in Explorer", c=get_path_explorer) # try to line up the current scene in the file list currFile = cmds.file(q=True, sn=True) if currFile: fileObj = uf.PathParser(currFile) if fileObj.compatible and (os.path.basename(currFile) in assetFiles): cmds.textScrollList(widgets["filesTSL"], e=True, si=os.path.basename(currFile)) else: # get the last file and select that numItems = cmds.textScrollList(widgets["filesTSL"], q=True, ni=True) cmds.textScrollList(widgets["filesTSL"], e=True, sii=numItems)
from functools import partial import maya.cmds as cmds import Utilities.assetInfo as ai import Utilities.utilityFunctions as uf # TODO # current scene info at top # change namespace functionality? right click # add import functionality # add replace ref functionaliity # add select top node in namespace functionality proj = ai.AssetInfo() widgets = {} refObjList = [] namespaceList = [] nameFilter = "*_main_*_v*.m?" # this means we're filtering for file name structure and ONLY 'main' type. Change this if necessary def asset_UI_create(*args): """ ui """ if cmds.window("assetWin", exists=True): cmds.deleteUI("assetWin") w = 820 h = 550 widgets["win"] = cmds.window("assetWin", t="Asset Manager", w=w, h=h)