Technofreak
04-15-2004, 08:54 AM
hi all, I'm just wondering if theres a easy way on doing this.......my problem is let say I've got 100 max scene file and maybe I need to set up something (scale or move my object...etc) on each file is there a command to tell Max to open each file and modify that object and then save that file again?.....this is how I would do it in Maya:
global proc gdp_newNames()
{
global string $targetDirectory;
string $path = $targetDirectory;
string $tempPath = gdp_currentSceneName();
string $command = ("global proc nn_renameGamePath()\r\n{ \r\n\tstring $files[] = `ls -type \"file\"`; \r\n\r\n\tfor ($file in $files)\r\n\t{\r\n\tint $nTokens = 0;\r\n\tstring $buff[0];\r\n\tstring $originalPath = `getAttr ($file + \".fileTextureName\")`; \r\n\r\n\t$nTokens = `tokenize $originalPath \"//\" $buff`; \r\n\r\n\tchangeGameDir($nTokens, $file, $buff);\r\n\t} \r\n}\r\n\r\n\r\nglobal proc changeGameDir(int $nTokens, string $file, string $dummy[])\r\n{\t\r\n\tstring $pathSource = " + $tempPath + ";\r\n\tstring $sourceImagePath = fromNativePath($pathSource);\r\n\tstring $fileName = ($dummy[$nTokens - 1]);\r\n\r\n\tsetAttr -type \"string\" ($file + \".fileTextureName\") ($sourceImagePath + $fileName); \r\n}\r\nnn_renameGamePath();");
string $buffer[0];
string $sceneName[0];
string $allFolders = `system("dir \"" + $path + "\*.mb\" /b")`;
int $nTokens = `tokenize $allFolders "\n" $buffer`;
for ($i = 0; $i < $nTokens; $i++)
{ $sceneName[$i] = `strip $buffer[$i]`; }
string $native = fromNativePath($path);
for ($i = 0; $i < $nTokens; $i++)
{
file
-f
-options "v=0"
-typ "mayaBinary"
-o ($native + $sceneName[$i]);
if (!`objExists ($sceneName[$i] + "_script")`)
{ string $nodeName = `scriptNode -st 2 -bs $command -n ($sceneName[$i] + "_script")`; }
print($sceneName[$i] + "\n");
SaveScene;
}
}
This script basically opens all the Maya Binary files in the specified directory and it adds a sciptNode to the scene. Next time you open up those files the scriptNode will run and it will look for the correct path of the textures. So basically what I want is to tell Max to open all the files and modify something on each files then save it again.
Thanks All
global proc gdp_newNames()
{
global string $targetDirectory;
string $path = $targetDirectory;
string $tempPath = gdp_currentSceneName();
string $command = ("global proc nn_renameGamePath()\r\n{ \r\n\tstring $files[] = `ls -type \"file\"`; \r\n\r\n\tfor ($file in $files)\r\n\t{\r\n\tint $nTokens = 0;\r\n\tstring $buff[0];\r\n\tstring $originalPath = `getAttr ($file + \".fileTextureName\")`; \r\n\r\n\t$nTokens = `tokenize $originalPath \"//\" $buff`; \r\n\r\n\tchangeGameDir($nTokens, $file, $buff);\r\n\t} \r\n}\r\n\r\n\r\nglobal proc changeGameDir(int $nTokens, string $file, string $dummy[])\r\n{\t\r\n\tstring $pathSource = " + $tempPath + ";\r\n\tstring $sourceImagePath = fromNativePath($pathSource);\r\n\tstring $fileName = ($dummy[$nTokens - 1]);\r\n\r\n\tsetAttr -type \"string\" ($file + \".fileTextureName\") ($sourceImagePath + $fileName); \r\n}\r\nnn_renameGamePath();");
string $buffer[0];
string $sceneName[0];
string $allFolders = `system("dir \"" + $path + "\*.mb\" /b")`;
int $nTokens = `tokenize $allFolders "\n" $buffer`;
for ($i = 0; $i < $nTokens; $i++)
{ $sceneName[$i] = `strip $buffer[$i]`; }
string $native = fromNativePath($path);
for ($i = 0; $i < $nTokens; $i++)
{
file
-f
-options "v=0"
-typ "mayaBinary"
-o ($native + $sceneName[$i]);
if (!`objExists ($sceneName[$i] + "_script")`)
{ string $nodeName = `scriptNode -st 2 -bs $command -n ($sceneName[$i] + "_script")`; }
print($sceneName[$i] + "\n");
SaveScene;
}
}
This script basically opens all the Maya Binary files in the specified directory and it adds a sciptNode to the scene. Next time you open up those files the scriptNode will run and it will look for the correct path of the textures. So basically what I want is to tell Max to open all the files and modify something on each files then save it again.
Thanks All
