## MaterialLibrary

Object Hierarchy | Related C++ Class: MaterialLibrary

### Inheritance

###

SIObject

ProjectItem

Source

Library

MaterialLibrary

### Introduced

v5.0

### Description

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.

### Methods

AddCustomOp | AddICEAttribute | AddProperty | AddScriptedOp
AddScriptedOpFromFile | AnimatedParameters2 | BelongsTo | CreateMaterial
EvaluateAt | GetICEAttributeFromName | IsA | IsAnimated2
IsClassOf | IsEqualTo | IsKindOf | IsLocked
IsSelected | LockOwners | RemoveICEAttribute | SetAsSelected
SetCapabilityFlag | SetLock | TaggedParameters | UnSetLock

### Properties

Application | BranchFlag | Capabilities | Categories
EvaluationID | Families | FullName | Help
HierarchicalEvaluationID | ICEAttributes | Items | LockLevel
LockMasters | LockType | Model | Name
NestedObjects | ObjectID | Origin | OriginPath
Owners | PPGLayout | Parameters | Parent
Parent3DObject | Properties | Selected | Type

### Examples

#### Python Example

    #

    #   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.

### See Also

Library