Any of you script monkeys want to show off?
I love painting in .psds but like to bring them down to bmps, jpgs and tgas.. nowadays its getting really time consuming to do all the repathing!
I would like to see a script that looks at all the maps in a max scene (or selected objects if you want to be really nice), finds any with the .psd extension, checks if there are any other maps with the same name but with any other extension in the folder and switches them automatically.
So a material with "bobshead.psd" finds "bobshead.jpg" in the same folder and decides to swap it.
Cheers!
Replies
EDIT: working on it now, :P.
I'll be able to reuse some material handling from another script I wrote, so it shouldn't take -too- long.
I'll post it when he makes it, probably in the next week or so.
It's not a hard script to write in theory. Is it all the materials in the scene, or all the materials in the material editor?
I take it you are also using multi-sub objects?
Unless I can see another way, it will only work with build in max shaders - my method wouldn't work with some 3rd party ones as they don't always provide an API.
Basically:
There are 24 material slots, so for each slot:
Check to see if the matial is of type bitmap
Check each sub material.
Check each map slot (difuse, spec, bump etc)
get the image extension (easy)
if its psd, get the full path, get the file name withour extension
build a new string of path+file+ ".jpg"
set current mateiral to use the new path.
If none of the other guys get you one, I'll knock you one up. The edinburgh festival is wrapping up, and I still have a few comedy shows to go to and 2 gigs (The Licks and The Pixies, yay!) so it'd be next week before I got a chance.
Some quick bits
for the ENTIRE SCENE use
for i in $* do
(
do stuff
)
)
check to see if the material is actaully a bitmap before trying to swap it
if classOf theMaterial == BitmapTexture then
For each material, check to see if it is a multisub. If not, call the switching extension funtion ont he material. If it is, get the number of subs, and then for each sub call it.
I'd have a go at home, but Max doesn't run on my mac.
It's basically a .psd with a .tif extension and 3D Studio reads it just as if it were a flat targa.
That is what I do.
*Ack after re-reading this thread, I understand the problem.
Very few engines use .tif, and even if you backed up your layered version, and flattened the ones used in the scene...they would still be .tifs, which would require you to convert & repath pre-export if the engine didn't support .tif's.
Right?...or am I just not getting it?
I just have to learn how to do file searching and string modification to do what Dave wants.
Forgot to transfer a work in progress version to my home computer to work on it tonight, so it'll have to wait till work/after work tomorrow.
Returns the file name and extension of a full file name, useful for labeling file buttons in rollout panels.
getFilenamePath <filename_string>
Returns the directory path part of a full file name.
getFilenameFile <filename_string>
Returns the file name part of a full file name.
getFilenameType <filename_string>
Returns the type extension part of a full file name.
doesFileExist <filename_string>
Returns true if the file exists, false otherwise
Examples:
file="g:\\subdir1\\subdir2\\myImage.jpg"
filenameFromPath file -- returns: "myImage.jpg"
getFilenamePath file -- returns: "g:\subdir1\subdir2\"
getFilenameFile file -- returns: "myImage"
getFilenameType file -- returns: ".jpg"
Blur Studios' ChangeBitmaps does a great job:
http://www.neilblevins.com/blurscripts/blurscripts.htm
Also does paths. You can limit it to certain criteria too... All Scene Materials, Materials On Selected Objects, etc.
Or you could use their Renamer, which does even more.
But I guess you want something a bit smarter, that checks to see if the new extension exists?
FWIW, I made screengrabs of those two tools, so you can see what they do.
I wouldnt use layered tiffs because the end result needs to be small and FTP'able.
Thanks all for your help and I hope you enjoyed the mental work out!
Dave
________________________
Max 8 has a make pretty button.