BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Thursday, May 13, 2010

Make all file textures relative

Here's a quick way to make all file textures in a scene relative. So that the path will read "sourceimages/filetexture.dds"

string $fileNodes = `ls -type file`;

for ($c in $fileNodes) {
string $path = `getAttr ($c + ".fileTextureName")`;
string $temp[];
string $temp2[];
tokenize $path "/" $temp;
tokenize $temp[`size($temp)` - 1] "\\" $temp2;
if ($temp2[`size($temp2)` - 1] == "") {
delete $c;
}
else {
string $newPath = "sourceimages\\" + $temp2[`size($temp2)` - 1];
setAttr -type "string" ($c + ".fileTextureName") $newPath;
}
}

0 comments: