## SceneItem.AddMaterial

### Description

Creates and adds material to a SceneItem object. If the SceneItem is a Model then the BranchFlag will be ignored since a material can only be added on a Model in branch.

### C# Syntax

    Material SceneItem.AddMaterial( Object in_Preset, Boolean in_Branch, String in_name );

### Scripting Syntax

    oReturn = SceneItem.AddMaterial( [Preset], [BranchFlag], [Name] );

### Return Value

Material

### Parameters

Parameter | Type | Description
--- | --- | ---
Preset | Variant containing a preset object (see SIGetPreset) or name | Shader preset or the name of a shader preset to apply to an object. Default Value: If no shader preset is supplied then a material is created and added with a phong shader connected to its surface port.
BranchFlag | Boolean | Apply material on branch or the node of object Default Value: false
Name | String | Represents the name of the new Material object

### Examples

#### VBScript Example

    set oRoot = application.activeproject.activescene.root

    set oCube = oRoot.AddGeometry("Cube","MeshSurface")

    set oMaterial = oCube.AddMaterial("Phong", siBranch)

    LogMessage "Cube's material name: " & oMaterial.FullName