Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hmasato/5719576 to your computer and use it in GitHub Desktop.

Select an option

Save hmasato/5719576 to your computer and use it in GitHub Desktop.
[MAYA, Realflow] _changeAbsPathToRelPath_forRealflowBIN
proc _changeAbsPathToRelPath_forRealflowBIN()
{
string $sn = `file -q -sn`;
string $sd = dirname($sn);
string $buf[]={};
if(catchQuiet( $buf=`ls -type "RealflowMesh"` )) return;
if(catchQuiet( $buf=`ls -type "RealflowEmitter"` )) return;
clear $buf;
string $RFs[]=`ls -type "RealflowMesh"`;
for($i = 0; $i < size($RFs); $i++){
string $rf = $RFs[$i];
string $rfn = getAttr($rf+".Path");
string $rfd = substituteAllString($rfn, match("_[0-9]+.bin$", $rfn), "");
$rfdn = basenameEx($rfd);
string $dir = $sd+"/"+$rfdn;
string $new = substituteAllString($rfn, dirname($rfn), $dir);
print("change "+dirname($rfn)+"\n");
print(" --> "+$new+"\n");
setAttr ($rf+".Path") -type "string" $new;
}
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+"]");
string $rfdn = match(".*[^_]", $rfp);
string $dir = $sd+"/"+$rfdn;
print("change "+$rfn+"\n");
print(" --> "+$dir+"\n");
setAttr ($rf+".Paths["+$j+"]") -type "string" $dir;
}
}
}
_changeAbsPathToRelPath_forRealflowBIN();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment