View Full Version : how to update scene obj material from .mat lib using script
zheng 03-01-2012, 04:45 PM how to update scene obj material from .mat lib using script??
|
|
Raytracer05
03-02-2012, 11:54 AM
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..
zheng
03-14-2012, 04:29 PM
i tried running the script but i get -- no "map" function for undefined -- error msg
or am i running it wrongly?
Raytracer05
03-14-2012, 05:33 PM
You must have at least one object selected or supply your own collection of objects instead of the "$".
CGTalk Moderation
03-14-2012, 05:33 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.