Notifications
Clear all
[Closed] Trouble With Basic Material Switching
May 02, 2015 10:32 pm
I’m terrible at Maxscript and have tried to cobble together a script that loops through the current selection and if it finds a material with any refraction value greater than black, it replaces that material with a shell material with the original material as the render material and the baked material as a standard Max material with a 20% opacity.
Here is what I have so far:
( if selection.count!=undefined do
(
MatBank=#()
indexMat=1
for i in 1 to selection.count where selection[i].material!=undefined do append MatBank selection[i].material
for i=1 to MatBank.count do
(
if (classof (MatBank[i]) ==multiMaterial) then (for j in 1 to MatBank[i].numsubs do
(
if (MatBank[i].materialList[j].refraction.red >0) then ($.material = Shell_Material originalMaterial:(MatBank[i].materialList[j])
MatBank[i].materialList[j].viewportMtlIndex = 1
MatBank[i].materialList[j].bakedMaterial.opacity = 20) else (print "not glass")
))
else (
if (MatBank[i].refraction.red >0) then (MatBank[i] = Shell_Material originalMaterial:(MatBank[i])
MatBank[i].viewportMtlIndex = 1
MatBank[i].bakedMaterial.opacity = 20) else (print "not glass")
)
)
)
)