using MaxScript to apply a batch effect to many files/objects?


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!


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
  	uvmap = UVWMap()
  	$.addmodifier(uvmap) --add it to all selected nodes
     savemax file

Hope this helps.


Hey thanks, I appreciate it. This should save me some time.


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.