View Full Version : using MaxScript to apply a batch effect to many files/objects?


Ghostscape
07 July 2004, 02:22 PM
I am working on a game with some friends of mine, and I need to generate a second set of UV coordinates for all of my meshes (probably about 200 so far) so we can bake lightmaps. I know I can use the automatic unwrapping in the "render to texture" dialog to unwrap each model with a second set of UVs that keep the UVs for each poly unique, but I'm not sure if it's possible to build a script that would (ideally)open a file, put each model in the file at the world origin, apply the automatic unwrapper to generate new UVs in the second UV channel, and then use our exporter with certain settings.

I don't know if any or all of this is possible, so if you know if this is possible or not, I'd appreciate it. If you have a script that does something similar that I could modify, I'd love it.

I'm looking into MaxScript right now, but I'm on a time crunch and don't want to waste my time if this is something that can't be done.

Thank you very much for your help!

dlanier
07 July 2004, 05:44 AM
Hi Ghostscape,

Yes, all what you said is possible. You can control the UVW Unwrap or UVWMap modifiers by using Maxscript. You have enable the macrorecorder in Max and do what you need manually, it will be translated into Maxscript code.

If I were you, I would start by getting all files from a directory, here is a small sample to use as a starting point :



local Mydirectory ="c:\SomeDirWhereMyMaxFilesAre"
local filesarray = getfiles ( Mydirectory+ "\\*.max" )
for file in filesarray do
(
loadmaxfile file
--do what you need on the file
selectall()
uvmap = UVWMap()
--etc...
$.addmodifier(uvmap) --add it to all selected nodes
savemax file
gc()
)


Hope this helps.
Regards,

Ghostscape
07 July 2004, 06:29 PM
Hey thanks, I appreciate it. This should save me some time.

CGTalk Moderation
01 January 2006, 07:00 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.


1