[Closed] Automated Material Editing
I am not a scripter but I think this is a job for MAXscript but I’m wondering if some scripted tool already exists to do this kind of thing.
I have thousands of materials in a scene where each material has a 24bit JPG in the diffuse slot. I am creating a B/W GIF as an opacity map for each material. The GIFs will have the same exact name as the file in the diffuse slot only it will have a GIF extension.
Is there a tool that will load each material, copy the path/filename in the diffuse slot and insert it into the opacity map slot with a GIF extension and turn on the opacity map checkbox and save the material when done?
Thanks for any ideas!
Hi,
Try somthing around these lines:
(
mats= for m in sceneMaterials collect m
for m in mats do
(
Diff=m.diffuseMap
if classof Diff == bitmapTexture do
(
d=Diff.fileName
o=GetfileNamePath d + GetfileNameFile d + ".gif"
Opa = bitmapTexture filename:o
m.opacityMap = Opa
)
)
)
Note: this works for standard material ONLY…
The script works great but there is one issue. The thousands of objects that this is run on currently have artifacts in the render because of the Blur value in the Texture Coordinates panel.
What is the Maxscript parameter that controls this blur value so that when added to this script will let me set the Blur value for both the Diffuse map and Opacity map?
Thanks again for this tool!
Diff.coords.blur = 0.0 (defaults to 1.0, I think)
-- Diff.coords.Blur_Offset = 0.0 (should default to 0.0 already)
Similar for ‘Opa’
as far as the above script goes its: m.opacityMap.coords.blur
I built a script to do this type of mass editing like changing all blur settings. It wont do complex stuff like copying the diffusemap but you might find it useful:
http://www.scriptspot.com/3ds-max/modifier-modifier-zorb
Thanks very much for these pointers… greatly appreciated!
Thanks again.
OK, this script has been working great (thanks!) but now I need to change it slightly. I know this is simple but not being a scripter, I don’t know how to do it.
The script modifies ALL scene materials. I need it to modify only the materials on the selected objects.
When I change ‘sceneMaterials’ to ‘selection’… it bombs. What do I need to add to make it work on the selected objects only?
Thanks again!
I haven’t seen the code, but you need to collect the Materials on the selected objects just before the loop that effects them…
SelectedMaterials = #()
for SelObj in Selection do
if ( isProperty SelObj #material ) do
if ( SelObj.material != undefined ) do
append SelectedMaterials SelObj.material
Then replace sceneMaterials with the variable SelectedMaterials
(
mats= for o in selection WHERE o.material != undefined collect o.material
for m in mats do
(
Diff=m.diffuseMap
if classof Diff == bitmapTexture do
(
d=Diff.fileName
o=GetfileNamePath d + GetfileNameFile d + ".gif"
Opa = bitmapTexture filename:o
m.opacityMap = Opa
)
)
)
The “sceneMaterials” variable holds materials, however the “selection” variable holds 3d Studio objects, so you need to access their material property. I also added a quick filter to skip objects that have no material assigned.
EDIT: woops, got here a second late =P. In any case, is it necessary to check that the node has a material property? I thought that everything that could be selected had a material property.