Having issues with a batch process that would remove the modifier "MultiRes" from the stack for a group of .max files. I'm not quite sure which part of it isn't working but I have a feeling its the actual modifier removal part of the process. Any help would be well appreciated.
macroScript ExportAllAnimation category:"WIT" tooltip:"ExportAllAnimation"
(
global W_ExportAllAnimation, RO_ExportAllAnimation
rollout RO_ExportAllAnimation "Batch Export DSQ" width:304 height:80
(
edittext edtSourceDirectory "" pos:[88,8] width:184 height:16
label lbl1 "Source directory" pos:[8,8] width:80 height:16
button ChooseSourceDir ".." pos:[272,8] width:16 height:16
edittext edtExportDirectory "" pos:[88,32] width:184 height:16
label lbl2 "Export directory" pos:[8,32] width:80 height:16
button ChooseExportDirectory ".." pos:[272,32] width:16 height:16
button btnExport "Export" pos:[8,56] width:280 height:16
on ChooseSourceDir pressed do
(
source_dir = getSavePath()
edtSourceDirectory.text = (source_dir as string)
)
on ChooseExportDirectory pressed do
(
export_dir = getSavePath()
edtExportDirectory.text = (export_dir as string)
)
on btnExport pressed do
(
maxfiles = getFiles (edtSourceDirectory.text + "\\*.max")
if edtSourceDirectory.text == "" or edtSourceDirectory.text == "undefined" then
(
messagebox "No source directory."
return 0
)
exportdir = (edtExportDirectory.text + "\\")
if edtExportDirectory.text == "" or edtExportDirectory.text == "undefined" then
(
exportdir = (edtSourceDirectory.text + "\\")
)
for fl in maxfiles do
(
loadMaxFile fl
select obj
deleteModifier obj MultiRes
fname = exportdir + getFilenameFile(fl) + ".max"
exportFile fname
)
)
)
if W_ExportAllAnimation != undefined do
(
try( closeRolloutFloater W_ExportAllAnimation )
catch()
)
W_ExportAllAnimation = newRolloutFloater "ExportAllAnimation" 310 116
addRollout RO_ExportAllAnimation W_ExportAllAnimation
Replies
deleteModifier obj MultiRes
to
deleteModifier obj obj.modifiers[#Multires]
However, I don't see where you define 'obj', so the script probably still won't work (it will give you an error like, "no 'select' function for undefined", and will crash on the "select obj" line). If you need further help, just ask.
This is how a clean MultiRes function should look like
I iterate 20 times trough the clean function because in max 9+ sometimes it does not execute
That will delete all Multires on all objects in your scene.
However, the script still only runs through a single source directory. Do you guys know if Maxscript could handle a more thorough batch process that includes subdirectories as well?
Are any part of the names of the sub directories known?
You could probably patch something together using "getDirectories" and the "PathConfig Struct"
I'm sure Rob can blow your socks off with a way more awesome reply if not outright write a function for you....
While I'm at it (and since I'm still really new to max scripting) is there a better environment to do this sort of thing than wordpad? ultraedit comes to mind but I just want a way to debug this code without so much guess-work.
edit: Forgot to mention, it'll go through several files before returning an error of "-- Unable to convert: Undefined to type: String". It looks like its not removing the multires modifier either.
Declarations, Functions and Meat works best for me but not always, there are times I'll write functions in other places but in general I try to keep each piece in its section. As well as adhering to some kind of indenting rule(s).
Also 3dsmax2008-09 have a pretty good Maxscript editor. Main Menu > MAXScript > MAXScript Editor.
If your on older versions Notepad++ is pretty good.
I'm trying to set
logsystem.quietmode or setquietmode() , but I don't know why they don't work. any idea why max 5 would have an issue with these, or how they are meant to be used?
http://www.scriptspot.com/3ds-max/relink-bitmaps
This relink bitmap script might have some good pointers if you decide to go that route.
but this is over 2000 files, , we just need to strip the multires out of them. Many of the textures don't even exist anymore. It loops and gets rid of the multires, but someone has to sit there and click "continue" for each file.
Do you even need to worry about the map paths? Maybe just applying a standard material to the object and clear the material editor. In which case you might want to take a peak at this material cleaner script I wrote for some useful functions.
There you go. That should get you over your design hurdles and technical workarounds- the rest of the work is coming up with the actual code, but it is not difficult and it will be a good learning experience.