The Glitch: Via maxscript you can have two materials with the same exact name on two different objects in the scene. It will render both objects with the two different materials.
For those who don't know maxscript, when you try to apply a material with the same name as an already existing scene material you'll be prompt to rename it or replace existing.
What I'm after: Does anyone know of a way to do the replace method with a material that is either created via maxscript or brought into the max scene through reading in a mat lib file?
Because I have a shader in the max scene called "Screw" and I want to bring in a new material named the same exact thing "Screw" but I can not figure out a way to replace that material. I want to stay away from any dialog popping up that says to replace, I just want it to happen. This way if the screw material is in a multi-sub on accident, that will also get updated to the new one. I hope this makes sense. I hope you guys can help.
This below code reads in a .mat file and applies it to an object in the scene.
matFile = @"C:\Users\Crabs User\Desktop\trash\Shot001\MATERIALS\Box\Box.mat" loadMaterialLibrary matFile mats = for i = 1 to currentMaterialLibrary.count where superClassof currentMaterialLibrary[i] == material collect currentMaterialLibrary[i] userSel = selection as array for o in userSel where isValidNode o while mats.count > 0 do ( o.material = mats )