Here's a small code to save an Incremental version of your maya file, so basically, no need to go to Save-As-> type the Name Again, just Copy the code in a MEL Shelf button: and every-time you need make an Incremental save, hit that Button.
- global proc incrementalSave()
- {
- string $f=`file -q -sn`; // get file name
- string $ft[]=`file -q -typ`; // file type (mayaAscii, etc.)
- if ($f!="")
- {
- // * extracting base filename (path/basename) and version number *
- string $n[],$ext="";
- if (tokenize($f,".",$n)) $ext=$n[size($n)-1];
- if (size($n)>1) $f=substring($f,1, size($f)-size($ext)-1 );
- if ($ext!="") $ext=("."+$ext);
- int $x=0, $m=1, $v=0, $d=0, $w=1;
- while($x==0)
- {
- string $e=substring($f,size($f),size($f)); // last character (as string)
- if (gmatch($e,"[0-9]")) // last character was a number?
- {
- $v+=($m*(int)$e);
- $m*=10;
- $d++; // (count number of digits)
- $f=substring($f,1,size($f)-1); // chop last character
- }
- else $x=1;
- }
- // * renaming current file (with incremented version number) *
- $v++; // increment version number
- string $vs=("000000000"+(string)$v);
- if ($d<1) $d=2; if ($d>8) $d=8;
- $vs=substring($vs,size($vs)-$d+1,size($vs));
- $f=($f+$vs+$ext);
- if (`confirmDialog -t "Save [+]" -m ("Save Scene As '"+$f+"' ?") -b "Ok" -b "Cancel" -cb "Cancel" -ds "Cancel"`!="Cancel")
- {
- file -rename $f;
- if (`file -q -ex $f`)
- {
- if (`confirmDialog -t "File Already Exists" -m ("Overwrite already existing file '"+$f+"'?") -b "Yes" -b "No" -cb "No" -ds "No"`!="Yes")
- $w=0;
- }
- if ($w)
- {
- //FileMenu_SaveItem;
- warning("projMan: Saving File...");
- evalEcho("file -save");
- addRecentFile($f,$ft[0]); // add to the recent files list
- }
- }
- }
- else projectViewer SaveAs;
- }
- incrementalSave;
No comments:
Post a Comment