View Full Version : Change User Path for textures
orlenka 09-21-2007, 02:00 PM Hi everyone,
i'm looking for a solution to change User path of a 3dsMax file automatically.
We got a big production and we sent some works to freelances to help us. Then we took back their work to render it and here's the problem... All the maps for textures are located on the freelance's drives so we got to change the path file by file here... and we got lot of files :scream:
If someone has a solution, thanks thanks thanks
See ya
Orlenka
|
|
kikialex
09-21-2007, 02:22 PM
--change all the file paths to the selected dir
new_dir = getSavePath()
if ((new_dir != undefined) and (new_dir != "")) do
(
mat_t = getClassInstances bitmaptexture
for mu in mat_t do
(
fis = getFilenameFile (mu.filename)
fis += getFilenameType (mu.filename)
mu.filename = (new_dir + fis)
)
)
Gravey
09-21-2007, 02:58 PM
there's a great script you can get from scriptspot called Relink Bitmaps where you choose a directory and it will search recursively for the missing bitmaps and then 'relink' them. Works great and has a UI that shows you the missing maps so you know if there are still any missing after it has completed its search, at that point you could just choose another directory and have it serach there! Here's the link: http://www.scriptspot.com/3ds-max/relink-bitmaps
orlenka
09-21-2007, 02:59 PM
thanks...
I won't lie i'm new to maxscript. Can we launch those kind of script at the startup of the 3dsMax, like putting it in the max.ini or something else?
MoonDoggie
09-21-2007, 09:13 PM
Thanks for the plug Gravey, if you have any question about running the Relink Bitmaps script please ask here, I'm lurking.
-Colin
antonv
09-21-2007, 09:14 PM
Yes, you can add callbacks which run your scripts when you open a file. Look in reference for "callbacks", they are explained really well.
orlenka
09-21-2007, 09:19 PM
thanks guys ! :thumbsup: i give it a try to all your tips. I certainly come back with more questions:)
MoonDoggie
09-21-2007, 09:39 PM
Adding a callback seems unnecessary for everytime you open a file.
Personally, most of my files don't have missing bitmaps and when they do it's as easy as clicking a button I created to the relink-bitmaps script.
Maxscript->open script->Relink Bitmaps v1.08.ms->CTRL-A->(click and drag the contents of the script to an empty space on your interface) and now you have a button to run the script when you like.
-Colin
Just as a thought, I've written scripts that open up a file, alters it saves it, closes it then moves onto the next until all the files in a list or directory have been altered accordingly. Let me know if you'd like to try that approach I can certainly help.
Dan
orlenka
09-22-2007, 07:52 AM
hi dmak !
yes your approach seems really interesting! :) we got a lot of files to open and modify and re-save them in other directory. We would like to make it automatically to earn time in our production. If you have some ideas they're welcomed :thumbsup:
Thanks guys
I added the file opening and saving part to what kikialex had already posted.
Alrighty, here's the script:
/* first a couple of variables --*/
theDir = "C:\\directory_Where_MaxFiles_Are\\*.max"
myFiles = getfiles myDir
newPath = "C:\\directory_Where_Textures_Are\\"
/* run through each file --*/
for f in myFiles do
(
/* open each file --*/
loadMaxFile f quiet:true
/* get all missing maps --*/
mMaps = getClassInstances bitmaptexture
/* run through all missing maps --*/
for m in mMaps do
(
/* rename all missing maps --*/
fName = getFileNameFile m.filename
fExt = getFileNameType m.filename
newName = newPath+fName+fExt
)
/* save and close current file */
saveMaxFile ((getFileNameFile f)+"_updated.max")
)
messageBox "Done updating "+(myFiles.count)+" files."
Incase you're not familiar with maxscript, just open a new maxscript window from the maxscript pulldown, copy and paste the code above into the window and hit control-e or from the file pull down select "evaluate all" and it should start working.
The only thing I have to warn is that once it starts it won't stop unless you keep escape pressed or you wait for the script to run through all the files. So test it on a small group of files first to make sure it's doing what you want.
Let me know if you run into any problems. Good luck!
MoonDoggie
09-23-2007, 05:21 AM
Please note: the above will not search recursive sub-directories, check the max script help file for a recursive searching function.
orlenka
09-23-2007, 11:26 AM
Thanks guys! i'll try those scripts. I'll give you a feedback soon :thumbsup:
In response to moondoggie,
I meant for the files to all be placed in one directory (I assume orlenka, you can move all the files into one directory?) It will create a new copy of each file with "_updated" attached to the end.
Also, for the maps to all be placed in one directory. If you plan on setting up a more specific directory structure for this, then the script would have to be modified.
orlenka
09-23-2007, 08:33 PM
yes i can move the files where we want. Thanks for warning me :thumbsup:
MoonDoggie
09-24-2007, 04:27 PM
yes i can move the files where we want. Thanks for warning me :thumbsup:
Absolutely, my comment was merely a warning, I can't count how many times I've done something and it works, then I realize it missed a bunch of files, etc.
orlenka
09-24-2007, 07:01 PM
yeah i clearly see what you mean, i was confronted with some scripts mistakes today...i haven't imagined there were so many things to think about to finalyze a well working tool :eek:
CGTalk Moderation
09-24-2007, 07:01 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.