def version_up(*args): """ versions the current file based on Zed's class/modules """ filePath = cmds.file(q=True, sn=True) ver = vf.versionClass() ver.versionUp(filePath) load_asset_info()
#save file with automatic versioning import maya.cmds as mc import os import maya.cmds as mc import os import Utilities.versionFile as vf import Utilities.getFilePath as gfp ver = vf.versionClass() def run(*args, **kwargs): #0=save file for the get file fucntion filePath = gfp.getFilePath(0) ver.versionUp(filePath)
def save_file(self, *args): # assemble file name sel = [] if self.selBased: sel = cmds.ls(sl=True) if not sel: cmds.warning( "fileManager.save_as_new: You haven't selected anything! Make a selection and try again!" ) return () currscene = cmds.file(q=True, sn=True) if currscene: saveScene = cmds.confirmDialog( t="Save?", m="Should I save the current scene before writing new file?", button=["Yes", "No", "Cancel"], defaultButton="Yes", cancelButton="Cancel", dismissString="Cancel") if saveScene == "Yes": print "Saving current scene: {0}".format(currscene) cmds.file(s=True, f=True) elif saveScene == "No": pass elif saveScene == "Cancel": cmds.warning("Cancelling Save As New!") return () else: pass # cmds.warning("You must be in a named scene to continue!") # return() filepath = None assettype = cmds.optionMenu(self.assetTypeOM, q=True, value=True) if assettype == "Stages": basepath = "{0}/Stages".format(self.projEnvPath) else: basepath = "{0}/Assets/3D/{1}".format(self.projEnvPath, assettype) asset = cmds.optionMenu(self.assetOM, q=True, value=True) variant = cmds.textFieldGrp(self.variant, q=True, tx=True) if not uf.check_for_good_name(variant): cmds.warning("No underscores allowed in variant names!") return () phase = cmds.optionMenu(self.phaseOM, q=True, value=True) if assettype == "Stages": filepath = "{0}/{1}/{2}/Production/Maya/scenes/{3}_{4}_{5}_Work_v0001.mb".format( basepath, asset, phase, asset, variant, phase) else: filepath = "{0}/{1}/{2}/Work/Maya/scenes/{3}_{4}_{5}_Work_v0001.mb".format( basepath, asset, phase, asset, variant, phase) # confirm and save # export to temp, open that tempScene = None if self.selBased: tempScene = create_temp_scene(filepath) if tempScene: cmds.file(tempScene, open=True, f=True) else: return () write = "Cancel" confirm = cmds.confirmDialog( title="Save Confirmation", message="You are about to 'version up':\n{0}\n\nShould we continue?" .format(filepath[:-9]), button=("Create", "Cancel"), defaultButton="Save", cancelButton="Cancel", dismissString="Cancel", bgc=(.6, .5, .5)) if confirm == "Create": write == "Save" print "Saving. . .: ", filepath else: write == "Cancel" print "Canceling. . ." cmds.deleteUI(self.win) if write: ver = vf.versionClass() ver.versionUp(filepath) cmds.deleteUI(self.win) if tempScene and os.path.isfile(tempScene): print "saveNewWindows.save_file: Cleaning up temp scene {0}".format( tempScene) os.remove(tempScene) cmds.confirmDialog( m="Save successful! You're now in file:\n{0}".format( cmds.file(q=True, sn=True))) # Try to refresh the file manager window if cmds.window("fileWin", exists=True): fm.fileManager()