Notifications
Clear all

[Closed] Put Material to Scene

 TiW

I am writing a script and I need to ‘extract’ a material from a VRayMtlWrapper and put the material back to the scene. In a nutshell I want to replace the VRayMtlWrapper with its ‘.BaseMtl’

I can manipulate the material without any problems but I cannot update the scene materials with my edited version. A work around would be to assign all the objects my new material but if I could find a way to access the ‘Put Material To Scene’ button it would make life a lot easier.

Anyone have any ideas?
Thanks

3 Replies

Why not loop through the scene objects, if the .material of the object is the VrayMtlWrapper then assign the BaseMtl as the material?

-Eric

 TiW

Hey that is an option but the script is intended for some quite heavy scenes and I want to make this as fast as possible. It just seems like an awful lot more processing than is needed. I might resort to this if there is no other way

 TiW

I have worked out how to do it!

I am not sure it is the best method but if anyone else gets stuck in the future hopefully this might help.

I used the replace instances command

replaceInstances[font=Courier New] [/font]

 
replaceInstances sceneMaterials[x] MyMaterial
 

Seems to work great