ObjectMaterialSource

Returns or modifies the rendering material source 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.

The index of the render material used to render an object is specified in one of three ways:

  1. Material from layer.  The rendering material assigned to the layer is used.

  2. Material from object.  The rendering material assigned to the object is used.

  3. Material from parent.  For objects with parents, like objects in block instances, use parent's material. If no parent, treats as material from layer.

The default rendering material source for new objects is "material by layer."

Syntax

rhinoscriptsyntax.ObjectMaterialSource ( object_ids, source=None )

rhinoscript.object.ObjectMaterialSource ( object_ids, source=None )

Parameters

object_ids

Required.  String, Guid, or list of Strings or Guids.  The identifier of the objects.

source

Optional.  Number.  The new rendering material source.  If omitted, the current material source is returned.  Note, if object_ids is for more than one object, source is required.

Value

Description

0

Material from layer

1

Material from object

2

<unused>

3

Material from parent

Returns

Number

If a rendering material source is not specified,  the current rendering material source if successful.

Number

If a rendering material source is specified, the previous rendering material source if successful.

Number

If object_ids is for multiple objects, then the number of objects modified if successful.

Example

import rhinoscriptsyntax as rs

objects = rs.GetObjects("Select objects to reset rendering material source")

if objects:

    [rs.ObjectMaterialSource(obj, 0) for obj in objects]

Also See

ObjectMaterialIndex