Object Hierarchy | Related C++ Class: MaterialLibrary
MaterialLibrary
v5.0
The material library object is a specialized source library for storing and sharing materials. The storage may be internal or external. If internal, the library is saved in the scene file. If external, the library is saved in a separate file. The library can be exported to and imported from dotXSI or a native binary format.
# # This example illustrates how to get a material library and how to # enumerate all materials in a library # from win32com.client import constants as c app = Application app.NewScene( "", 0 ) # First create some libraries and materials sph = app.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" ) app.ApplyShader( "", sph, "", "", c.siLetLocalMaterialsOverlap ) rtn = app.CreateLibrary( "", 1 ) lib = rtn(0) #app.Selection.Add( lib ) lib.Name = "MyLibrary" app.SetCurrentMaterialLibrary( lib ) # Now enumerate all materials in all libraries scn = app.ActiveProject.ActiveScene matlibs = scn.MaterialLibraries app.LogMessage( "There are " + str(matlibs.Count) + " libraries under the scene." ) for currlib in matlibs : app.LogMessage( currlib.Name + " has " + str(matlibs.Count) + " defined materials." ) for currmat in currlib.Items : app.LogMessage( " - " + currmat.Name ) # Expected result: #INFO : There are 2 libraries under the scene. #INFO : DefaultLib has 2 defined materials. #INFO : - Scene_Material #INFO : - Material #INFO : MyLibrary has 2 defined materials. |