## Material

Object Hierarchy | Related C++ Class: Material

### Inheritance

SIObject

ProjectItem

Property

Material

### Introduced

v1.0

### Description

The Material object represents the material property of a SceneItem object and can be created with SceneItem.AddMaterial.

### Methods

AddCustomOp | AddICEAttribute | AddProperty | AddScriptedOp
AddScriptedOpFromFile | AddSharedTextureLayer | AnimatedParameters2 | BelongsTo
CreateTextureLayer | EvaluateAt | FindShaders | GetAllShaders
GetICEAttributeFromName | GetShaderInputType | IsA | IsAnimated2
IsClassOf | IsEqualTo | IsKindOf | IsLocked
IsResolved | IsSelected | LockOwners | RemoveICEAttribute
RemoveTextureLayer | Resolve | SetAsSelected | SetCapabilityFlag
SetLock | TaggedParameters | UnSetLock |

### Properties

AllImageClips | Application | Branch | BranchFlag
Capabilities | Categories | CurrentImageClip | CurrentTexture
CurrentUV | EvaluationID | Families | FullName
Help | HierarchicalEvaluationID | ICEAttributes | ImageClips
Library | LockLevel | LockMasters | LockType
Model | Name | NestedObjects | OGLMaterial
OGLTexture | ObjectID | Origin | OriginPath
Owners | PPGLayout | Parameters | Parent
Parent3DObject | Properties | Selected | Shaders
Singleton | TextureLayers | Type | UnresolvedFullname
UsedBy |  |  |

### Examples

#### VBScript Example

    '===================================================================
    '
    '       This example demonstrates how you can recursively
    '       find and print all the material in a scene.
    '
    ' Set up the scene first with three separate materials on
    ' the three mesh objects
    NewScene , false
    dim oThing
    set oThing = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )
    oThing.AddMaterial "Phong", , "Wanda"
    set oThing = ActiveSceneRoot.AddGeometry( "Disc", "MeshSurface" )
    oThing.AddMaterial "Lambert", , "Stewart"
    set oThing = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" )
    oThing.AddMaterial "Blinn", , "Lulu"
    ' Start a running tally (as a global index)
    dim g_Count
    g_Count = 0
    ' Now call the first routine
    FindAndPrintAllNodeMaterials
    ' The following information is logged in Softimage:
    'INFO : "These (3) materials were found:"
    'INFO : "sphere.Material"
    'INFO : "disc.Material"
    'INFO : "torus.Material"
    '-------------------------------------------------------------------
    ' This routine just launches the search for the materials by
    ' calling the workhorse routine. Notice how the second argument
    ' uses the byref keyword: that is so we preserve the collection
    sub FindAndPrintAllNodeMaterials
            ' Create an empty collection that the worker routine
            ' will fill with found materials
            dim oMats, m
            set oMats = CreateObject ( "XSI.Collection" )
            SIGetAllNodeMaterial ActiveSceneRoot, oMats
            ' When it's all done we'll have a collection of all
            ' the materials under the root (ie., all)
            Application.LogMessage "These (" & g_Count & ") materials were found:"
            for each m in oMats
                    Application.LogMessage m
            next
    end sub
    '-------------------------------------------------------------------
    ' This routine is the 'workhorse', it crawls down the whole graph,
    ' visiting each node to see if it's a material and collects
    ' it if it is.
    sub SIGetAllNodeMaterial( in_Obj, byref io_materials )
            ' Get the input objects properties and then loop
            ' through them looking for materials
            dim oProps, p
            set oProps = in_Obj.Properties
            for each p in oProps
                    if TypeName(p) = "Material" Then
                            ' Only add node materials
                            if Not p.Branch then
                                    ' Add them to the collection
                                    ' & increment the counter
                                    g_Count = g_Count + 1
                                    io_materials.Add p
                            end if
                    end if
            next
            ' This is the recursive part: by calling the
            ' SIGetAllNodeMaterial routine from inside the
            ' SIGetAllNodeMaterial routine, we're basically
            ' drilling down through the children.
            dim oChildren, c
            set oChildren = in_Obj.FindChildren
            for each c in oChildren
                    SIGetAllNodeMaterial c, io_materials
            next
    end sub

### See Also

TextureLayer