Here’s a snippet that shows how to loop through all material libraries and materials and delete unconnected shaders:
var oMatLibs = ActiveProject.ActiveScene.MaterialLibraries; oEnum = new Enumerator( oMatLibs ) ; for (;!oEnum.atEnd();oEnum.moveNext() ) { var oMatLib = oEnum.item() ; oEnum1 = new Enumerator( oMatLib.Items ) ; for (;!oEnum1.atEnd();oEnum1.moveNext() ) { var oMat = oEnum1.item() ; DeleteUnusedShaders( oMat ); } }
The same thing but in Python.
oMatLibs = Application.ActiveProject.ActiveScene.MaterialLibraries for lib in oMatLibs: for mat in lib.Items: Application.DeleteUnusedShaders( mat )
This loops though unconnected shaders, how would you modify this to select all materials in a model ? Hopefully I can learn from analyzing scripts 🙂
model = Application.Selection(0)
materials = [each.Material for each in model.FindChildren(“*”)]
Application.SelectObj(materials)
Python, obviously, thank you 🙂
To select all the materials that don’t contain a specific RenderTree node, would the compound name, or ProgID have to be added by a counter ?