Hi. I'm new to scripting and I'm currently working on script to modify existing materials that have been applied to objects.
There are several objects in the scene with different materials (and different textures) and the plan is to all unify them with certain values (self illuminating, blur, diffuse, specular, ambient etc) I can assign a *new* material to all the objects, but that's not what I want to do. I need to make a few changes (en masse) to the assigned materials and I'm not sure how to do that - me being new to scripting and all. Any suggestions? Thank you.
Forum topic · General Scripting
Modify existing materials
By ghoulfool · 2010-07-30
Description
Comments (4)
ghoulfool · 2010-08-02
Thank you Insanto, that makes a lot of sense and the code comments are appreciated as well!
And interesting there is no "purple" in MAXscript : but I worked out it was local col = color X Y Z for individual colours.
Graph · 2010-08-01
i wrote it in a way so you can expand on it quite easily, you just gotta know the class of the material and the settings
if you wanna find out the class you use:
classOf meditMaterials[1] --returns class of the materialEditor's first slot
to get the propertyNames and types you use:
showproperties meditMaterials[1]
-add the class to the classFilterFN function
-add a new case for the added materialClass with it's properties you wish to change
have phun
titane357 · 2010-08-01
cool, Insanto
could it be possible to have a line for Vray material too ? thanx
i suggest: ( local
Graph · 2010-07-30
i suggest:
(
local mats = #() -- create the empty array
fn classFilterFN mat = classOf mat == Arch___Design__mi OR classOf mat == standardMaterial -- function to filter all materialClasses that are to be modified
for obj in geometry do --loop through the geometry
(
local mat = obj.material -- assign the current object's material to a variable cuz im a lazy typer
if mat != undefined do -- check if the object has a material at all
(
if classOf mat != multisubmaterial then -- check if the material is a multiSub-object-material
(
if classFilterFN mat do -- check if the material's class is in the ones to be modified
(
mats[mats.count+1] = mat -- append the material to the 'mats' array
)
)
else -- if it is a multiSub-object-material..
(
for m in mat.materials do --loop through the multiSub-object-material's materials
(
if classFilterFN mat do -- check if the current material's class is in the ones to be modified
(
mats[mats.count+1] = mat -- append the material to the 'mats' array
)
)
)
)
)
for mat in mats do -- loop through the materials collected previously
(
local col = green
case (classOf mat) of -- handle each material class diffrently
(
Standardmaterial : ( mat.diffuse = col )
Arch___Design__mi : ( mat.diff_color = col )
)
)
)
:P