예제 #1
0
    def process(self, context):
        from avalon import maya

        assert not maya.is_locked(), (
            "This file is locked, please save scene under a new name. "
            "If you are sure of what you are doing, you can override this "
            "warning by calling cmds.remove('lock')")
예제 #2
0
    def process(self, context):

        if lib.in_remote():
            return

        if maya.is_locked():
            raise Exception("Scene has been locked, please save the scene "
                            "with another name.")
    def process(self, context):

        if context.data.get("contractorAccepted"):
            return

        if maya.is_locked():
            raise Exception("Scene has been locked, please save the scene "
                            "with another name.")
예제 #4
0
def before_save(return_code, _=None):
    """Prevent accidental overwrite of locked scene"""

    # Manually override message given by default dialog
    # Tested with Maya 2013-2017
    dialog_id = "s_TfileIOStrings.rFileOpCancelledByUser"
    message = ("Scene is locked, please save under a new name "
               "or run cmds.remove(\"lock\") to override")
    cmds.displayString(dialog_id, replace=True, value=message)

    # Returning false in C++ causes this to abort a save in-progress,
    # but that doesn't translate from Python. Instead, the `setBool`
    # is used to mimic this beahvior.
    # Docs: http://download.autodesk.com/us/maya/2011help/api/
    # class_m_scene_message.html#a6bf4288015fa7dab2d2074c3a49f936
    OpenMaya.MScriptUtil.setBool(return_code, not maya.is_locked())
예제 #5
0
    def process(self, context):
        from maya import cmds
        from avalon import maya

        assert any(
            inst.data.get("publish", True)
            for inst in context), ("No instance been published, aborting.")

        if maya.is_locked():
            return

        # Switch to masterLayer before save
        cmds.editRenderLayerGlobals(currentRenderLayer="defaultRenderLayer")

        # Rename scene file (Save As)
        scene_file = os.path.basename(cmds.file(query=True, sceneName=True))
        scene_dir = (cmds.workspace(query=True, rootDirectory=True) +
                     cmds.workspace(fileRuleEntry="scene"))

        basename, ext = os.path.splitext(scene_file)

        publishing_dir = scene_dir + "/_published/"
        publishing_file = basename + ".published%s" + ext
        publishing = None

        if not os.path.isdir(publishing_dir):
            os.makedirs(publishing_dir)

        exists = True
        suffix = ""
        index = 0
        while exists:
            publishing = publishing_dir + publishing_file % suffix
            failed = publishing_dir + "__failed." + publishing_file % suffix
            exists = os.path.isfile(publishing) or os.path.isfile(failed)
            index += 1
            suffix = ".%02d" % index

        context.data["originMaking"] = context.data["currentMaking"]
        context.data["currentMaking"] = publishing

        cmds.file(rename=publishing)

        # Lock & Save
        maya.lock()
        with maya.lock_ignored():
            cmds.file(save=True, force=True)
예제 #6
0
    def process(self, context):
        from avalon import maya

        if maya.is_locked():
            raise Exception("Scene has been locked, please save the scene "
                            "with another name.")