I am trying to write what I thought was a simple script, but it's not doing what I'd expect. I'm trying to open a material library, and apply the materials in it to a scene (as you would manually with the put to scene button), to update the materials in the scene. For one thing, the "put to scene" button no longer works in 2011 as I found out here: http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=1499331…
So taking their advice, I tried to automate making a box, and applying my matlib materials to it one at a time to replace the existing materials. I can watch the box colors change, but it doesn't replace the scene materials, it just makes a new scene material of the same name, that then disappears when the next material is applied.
My test scene has 4 box's each with a different VRaymat applied. My matlib has the same 4 materials with different diffuse values.
This is the script I'm using to test with:
loadmateriallibrary "X:\\Dummy\\Custom Maps\\dummy.mat"
tb=box()
select tb
cml=currentmateriallibrary
cmlC=cml.count
Messagebox "pause" --just for feedback
for n=0 to cmlC do -- when I set it n=1 here it didn't seem to apply
-- the first material
(
tb.material = cml[n]
show n
n=n+1
messagebox "Pause" --so I have time to see the colors change
)
delete tb
Does anyone know a way to accomplish this that is compatible with 2010 and 2011, and does not involve applying the new material to each object in the scene individually?
Anubis · 2010-10-01