MEL: Revert to saved

This script will revert back the current file to its last saved state in maya:

/*
Ehsan Iran-Nejad 2010 / Maya 2011 hotfix 3
Procedure Name:		revert
Description:		reverts a file to its last save
Input Arguments:	-none-
Return value:		"notSavedYet", "cancelled" OR file command results.
*/

//adds menuItem to mainFileMenu
global proc addRevertSubMenuItem() {
if(!`about -batch`) {
buildFileMenu;
global string $gMainFileMenu;
menuItem -l "Revert to saved" -c "revert" -ia saveAsItem -p $gMainFileMenu revertItem;
}
}

global proc string revert() {
string $fileName = `file -q -sn`;
if($fileName == "") { warning("File not saved yet..."); return "notSavedYet"; }
if(`confirmDialog -m "Revert to last saved state?" -b "Yes" -b "No" -db "Yes" -cb "No"` == "Yes")
	return `file -open -force $fileName`;
else return "cancelled";
}

Also don’t forget to add these two lines to userSetup.mel in your maya\scripts folder for the menu item to be appended to main file menu:

source revert.mel;
addRevertSubMenuItem;

Discuss - No Comments

No comments yet. Why not add one below?

Add a Comment

Your email address will not be published. Note marked required (*) fields.

*