how to update scene obj material from .mat lib using script??
If you want to update the material on an object or collection of objects then this should work:
( loadMaterialLibrary ((getDir #matlib)+"\\YourMaterialLibrary.mat") for obj in $ do ( if isProperty obj #material and obj.material != undefined then ( for mat in currentMaterialLibrary do ( if obj.material.name == mat.name then obj.material = mat ) ) ) )
Or if you want to update all scene materials with the same name as one in the library then:
( loadMaterialLibrary ((getDir #matlib)+"\\YourMaterialLibrary.mat") sMatN = for sMat in sceneMaterials collect sMat.name for lMat in currentMaterialLibrary do ( if findItem sMatN lMat.name != 0 then ( objs = for obj in geometry where obj.material != undefined and obj.material.name == lMat.name collect obj objs.material = lMat ) ) )
Hope this helps…
i tried running the script but i get – no “map” function for undefined – error msg
or am i running it wrongly?
You must have at least one object selected or supply your own collection of objects instead of the “$”.
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.