ObjectMaterialIndex

Returns the material index of an object.

Rendering materials are stored in Rhino's rendering material table.  This table is conceptually an array.  Render materials associated with objects and layers are specified by zero based indices into this array.

If the return value of ObjectMaterialSource is "material by object", then the return value of this function is the index of the object's rendering material.  A material index of -1 indicates no material has been assigned, and that Rhino's internal default material has been assigned to the object.

Syntax

rhinoscriptsyntax.ObjectMaterialIndex (object_id)

rhinoscript.object.ObjectMaterialIndex (object_id)

Parameters

object_id

Required.  String or Guid.  The identifier of the object.

Returns

Number

The rendering material index if successful.

Example

import rhinoscriptsyntax as rs

obj = rs.GetObject("Select object")

if obj:

    source = rs.ObjectMaterialSource(obj)

    if source==0:

        print "The material source is by layer"

    else:

        print "The material source is by object"

        index = rs.ObjectMaterialIndex(obj)

        if index==-1: print "The material is default."

        else: print "The material is custom."

Also See

ObjectMaterialSource