Ok, I just did a test and the script does nothing. This is what I changed in your script
1- Placed all remaining Max files (33 files that need to be merged and rendered) in "c:/temp/"
2- Set Max directory to "c:/temp/"
2- For rendering path I also gave "c:/temp/"
3- Pattern for Objects to load is "3_4SQ*"
4- All Materials are named properly in the script (same as what I have in my mat Browser)
5- Changed file format to Local type = ".jpg"
6- Created a dummy file selected 3 objects that need their material to change
7- Ran the script
8- Nothing is happening - don't know what I did wrong
below is the script modified with new names and path
-----------------------------------
fn customRenderScene dir: prefix:"" =
(
local nodes = selection as array
local cam = cameras[1]
local image_names =
#(
"ANTIQUE BRASS",
"ANTIQUE COPPER",
"ANTIQUE GOLD",
"BRUSHED CHROME",
"BRUSHED NICKEL",
"BRUSHED STAINLESS STEEL",
"SATIN BRASS",
"SATIN BRONZE",
"SATIN COPPER",
"SATIN CHAMPIGNE",
"SATIN GOLD",
"SATIN CHROME",
"SATIN NICKEL",
"POLISHED CHROME",
"POLISHED NICKEL",
"POLISHED STAINLESS STEEL",
"POLISHED BRASS",
"POLISHED COPPER",
"POLISHED ALUMINUM",
"MATTE ALUMINUM",
"MATTE IRON",
"OIL RUBBED BRONZE",
"MATTE BLACK",
"MATTE WHITE"
)
if dir == unsupplied do dir = @"C:/temp/"
local type = ".jpg"
if nodes.count > 0 and iskindof cam Camera do
(
num_mats = 24
for k=1 to num_mats where iskindof (mat = meditmaterials[k]) Material do
(
if keyboard.escpressed do (return false)
nodes.material = mat
image_name = dir + (prefix + image_names[k]) + type
format "\t% >> " k
bmp = render cam:cam outputfile:image_name
format "%\n" bmp
bmp
)
return true
)
return false
)
--bmps = customRenderScene()
fn mergeAndRender dir: =
(
dir = "c:/temp/" -- path for source files
files = getfiles (dir + "*.max")
out_render_path = "c:/temp/" -- path where to save render (must exist!!!)
pattern = "3_4SQ*" -- pattern for objects to load
out = false
for file in files do
(
if out or (out = keyboard.escpressed) do
(
format "\t\tCANCELED BY INTERRUPTION\n"
return ()
)
format "file: % ...\n" file
if (getFileAttribute file #readonly) then
(
format "\tSKIPPED AS READONLY\n"
)
else
(
all_names = getMAXFileObjectNames file quiet:on
names = for name in all_names where matchpattern name pattern:pattern collect name
with printallelements on format "\tnodes:%\n" names
delete selection
mergemaxfile file names #select #alwaysReparent #deleteOldDups #useSceneMtlDups quiet:on
prefix = tolower (getFilenameFile file) + "_"
res = customRenderScene dir:out_render_path prefix:prefix
if not res then
(
format "\n\t\tINTERRUPTED BY CONDITION\n"
return #abort
)
else
(
format "\tDONE\n"
)
)
)
#done
)
/********** USING *************
mergeAndRender()
*****************************/