## Library

Object Hierarchy | Related C++ Class: Library

### Inheritance

###

SIObject

ProjectItem

Source

Library

### Introduced

v4.0

### Description

A library is a container of objects of the same kind. For example, a material library contains a list of materials. The storage of a library can be either internal or external. For internal storage, it is saved within the scene file. For external, it is saved in a separate file. The library can be exported and imported into a dotXSI format or a native binary format.

### Methods

AddCustomOp | AddICEAttribute | AddProperty | AddScriptedOp
AddScriptedOpFromFile | AnimatedParameters2 | BelongsTo | 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

#### JScript Example

    /*

    	This example illustrates how to get a material library and how to

    	enumerate all materials in a library

    */

    NewScene(null, false);

    // First create some libraries and materials

    CreatePrim("Sphere", "MeshSurface");

    ApplyShader(null, "", null, "", siLetLocalMaterialsOverlap);

    CreateLibrary();

    SelectObj("Sources.Materials.MaterialLibrary");

    SetValue("Sources.Materials.MaterialLibrary.Name", "MyLibrary");

    SetCurrentMaterialLibrary("Sources.Materials.MyLibrary");

    SelectObj("sphere", null, true);

    ApplyShader(null, "", null, "", siLetLocalMaterialsOverlap);

    // Now enumerate all materials in all libraries

    var oScene = Application.ActiveProject.ActiveScene;

    var oMaterialLibraries = oScene.MaterialLibraries;

    Application.LogMessage("There are " + oMaterialLibraries.Count + " libraries under the scene.");

    for( var i=0; i<oMaterialLibraries.Count; i++ ) {

    	var oLibrary = oMaterialLibraries(i);

    	Application.LogMessage(oLibrary.Name + " has " + oLibrary.Items.Count + " defined materials");

    	var oMaterials = oLibrary.Items;

    	for( var j=0; j<oMaterials.Count; j++ ) {

    		Application.LogMessage("  - " + oMaterials(j).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 1 defined materials

    // INFO :   - Material

### See Also

Scene.ActiveMaterialLibrary