## SelectMaterialsUsedBy

### Introduced

v5.0

### Description

Selects all the materials being 'used by' the input object(s) which can include 3DObjects, clusters, groups, layers and partitions. For a 3DObject this includes the materials on clusters and subsurfaces.

### Scripting Syntax

    SelectMaterialsUsedBy( InputObjs );

### Parameters

Parameter | Type | Description
--- | --- | ---
InputObjs | String | List of objects Default Value: Current selection

### Examples

#### 1. VBScript Example

    '
    ' The following example creates a couple of objects and places them in a group.
    ' Then it adds a material (green in color) to the group.  Thus that material is
    ' inherited by the two objects.  Then it demonstates this command.
    '
    NewScene , False
    ' Create a couple of objects
    SetDisplayMode "Camera", "shaded"
    set oRoot = Application.ActiveSceneRoot
    set oCube = oRoot.AddGeometry("Cube","MeshSurface", "Green_Cube")
    set oCone = oRoot.AddGeometry("Cone","MeshSurface", "Green_Cone")
    Translate "Green_Cone", 7.57946639200555, -4.14387414395287E-02, 4.14387414395287E-03, siRelative, siView, siObj, siXYZ, , , , , , , , , , 0
    ' Create a group and add the two objects
    set oGroup = oRoot.AddGroup
    oGroup.AddMember(oCube)
    oGroup.AddMember(oCone)
    ' Create a material (green in color) on the group
    set oMaterial = oGroup.AddMaterial("Phong", siBranch, "GREEN_Material")
    SetValue "Sources.Materials.DefaultLib.GREEN_Material.GREEN_Material.diffuse.red", 0
    SetValue "Sources.Materials.DefaultLib.GREEN_Material.GREEN_Material.diffuse.green", 1
    SetValue "Sources.Materials.DefaultLib.GREEN_Material.GREEN_Material.diffuse.blue", 0
    ' Select the material 'used by' an object in the group.
    DeselectAll
    SelectMaterialsUsedBy "Green_Cone"
    ' The material 'GREEN_Material' should now be selected.

#### 2. JScript Example

    /*
            The following example creates an object and adds a material (red in color)
            on it.  Then it demonstates this command.
    */
    NewScene( null, false );
    // Create an object
    SetDisplayMode("Camera", "shaded");
    var oRoot = Application.ActiveSceneRoot;
    var oObject = oRoot.AddGeometry( "Cylinder", "MeshSurface" );
    // Add a material (red in color) on it
    var oMaterial = oObject.AddMaterial( "Phong", siNode, "RED_Material" );
    SetValue("Sources.Materials.DefaultLib.RED_Material.RED_Material.diffuse.red", 1, null);
    SetValue("Sources.Materials.DefaultLib.RED_Material.RED_Material.diffuse.green", 0, null);
    SetValue("Sources.Materials.DefaultLib.RED_Material.RED_Material.diffuse.blue", 0, null);
    // Select the material(s) used by the object
    DeselectAll();
    SelectMaterialsUsedBy("cylinder");
    // The material 'RED_Material' should now be selected.
    //

### See Also

SelectObjectsUsingMaterial