Skip to content

Instantly share code, notes, and snippets.

@hmasato
Last active December 17, 2015 04:39
Show Gist options
  • Save hmasato/5552478 to your computer and use it in GitHub Desktop.
Save hmasato/5552478 to your computer and use it in GitHub Desktop.
[Maya, Realflow, Win] RF_makeCopyBat.mel
proc RF_makeCopyBat()
{
if(!`pluginInfo -q -l "realflow"`) return;
string $buf[]={};
if(catchQuiet( $buf=`ls -type "RealflowMesh"` )) return;
if(catchQuiet( $buf=`ls -type "RealflowEmitter"` )) return;
clear $buf;
string $sn = `file -q -sn`;
string $sd = dirname($sn);
string $tmp = getenv("TEMP");
string $fn = $tmp+"/"+basenameEx($sn)+"_rfpack.txt";
int $fd=fopen($fn, "w");
int $nRF = 0;
fprint($fd, "rem "+$sn+"\r\n");
fprint($fd, "\r\n");
string $RFs[]=`ls -type "RealflowMesh"`;
for($i = 0; $i < size($RFs); $i++){
string $rf = $RFs[$i];
string $rfn = getAttr($rf+".Path");
$rfn = substituteAllString($rfn, "/", "\\");
string $rfd = substituteAllString($rfn, match("_[0-9]+.bin$", $rfn), "");
$rfdn = basenameEx($rfd);
string $dir = $sd+"/"+$rfdn;
$dir = substituteAllString($dir, "/", "\\");
fprint($fd, "rem "+$nRF+": "+$rfdn+" for "+$rf+"\r\n");
fprint($fd, "if not exist "+$dir+" mkdir "+$dir+"\r\n");
fprint($fd, "copy /y "+$rfd+"_?????.bin"+" "+$dir+"\r\n");
fprint($fd, "\r\n");
$nRF ++;
}
string $RFs[]=`ls -type "RealflowEmitter"`;
for($i = 0; $i < size($RFs); $i++){
string $rf = $RFs[$i];
int $n = `getAttr -s ($rf+".Paths")`;
for($j = 0; $j < $n; $j++){
string $rfn = getAttr($rf+".Paths["+$j+"]");
string $rfp = getAttr($rf+".Prefixes["+$j+"]");
$rfn = substituteAllString($rfn, "/", "\\");
string $rfdn = match(".*[^_]", $rfp);
string $dir = $sd+"/"+$rfdn;
$dir = substituteAllString($dir, "/", "\\");
fprint($fd, "rem "+$nRF+": "+$rfdn+" for "+$rf+"\r\n");
fprint($fd, "if not exist "+$dir+" mkdir "+$dir+"\r\n");
fprint($fd, "copy /y "+$rfn+"\\"+$rfdn+"_?????.bin"+" "+$dir+"\r\n");
fprint($fd, "\r\n");
$nRF ++;
}
}
fclose($fd);
if($nRF > 0){
system( "shell "+substituteAllString($fn, "/", "\\") );
}
}
RF_makeCopyBat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment