Beispiel #1
0
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()
def save_as_new(*args):
    # construct the paths
    filePath = None
    selTab = cmds.tabLayout(widgets["assetsTab"], q=True, st=True)
    if selTab != "STGS":
        tab, phase, assetPath, assetFiles = get_asset_info()
    else:
        tab, phase, assetPath, assetFiles = get_stage_info()

    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]
    else:
        cmds.warning(
            "You need to select either a file OR 'No Files' in the file lister on the right."
        )
    # if there is no file present, create the path based on asset and phase
    if 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 = fix_path(os.path.join(assetPath, filename))

    # or use the path from selections
    else:
        filePath = fix_path(os.path.join(assetPath, assetFiles[selIndex - 1]))

    # if file already exists then bail out
    if os.path.isfile(filePath):
        cmds.confirmDialog(
            title="File Exists!",
            message=
            "This file type already exists, you should use the version up instead!",
            button=("OK"))
        return ()

    confirm = cmds.confirmDialog(
        title="Save Confirmation",
        message="You are about to create:\n{0}\n\nShould we continue?".format(
            filePath),
        button=("Create", "Cancel"),
        defaultButton="Save",
        cancelButton="Cancel",
        dismissString="Cancel",
        bgc=(.6, .5, .5))
    if confirm == "Create":
        write = True
    else:
        write = False

    if write:
        ver = vf.versionClass()
        ver.versionUp(filePath)

    populate_files()
Beispiel #3
0
#save file with automatic versioning
import maya.cmds as mc
import os

import maya.cmds as mc
import os

import Utilities.versionFile_v02 as vf
import Utilities.getFilePath_v01 as gfp
reload(vf)
reload(gfp)
ver = vf.versionClass()


def run(*args, **kwargs):
    #0=save file for the get file fucntion
    filePath = gfp.getFilePath(0)
    if mc.file(filePath, q=1, ex=1):
        ver.versionUp(filePath)
    else:
        mc.file(rn=filePath)
        mc.file(s=1, f=1)