Click or drag to resize

MaterialTableItem Property

Conceptually, the material table is an array of materials. The operator[] can be used to get individual materials. A material is either active or deleted and this state is reported by Material.IsDeleted.

Namespace:  Rhino.DocObjects.Tables
Assembly:  RhinoCommon (in RhinoCommon.dll)
Syntax
public Material this[
	int index
] { get; }

Parameters

index
Type: SystemInt32
zero based array index.

Return Value

Type: Material
If index is out of range, the current material is returned.
Remarks
Detaching a worksession reference model, or purging a linked instance definition, removes its materials but leaves the table slots they occupied empty; the slots cannot be closed up, because table indices are persistent references that objects store. Count spans the empty slots and they accumulate for the life of the document. An index that lands on one returns the default material rather than throwing, and nothing about it says it is a stand-in except its index, which is -1 and never the index you asked for - so test index == Materials[index].Index before treating an entry as real. Enumerating the table with foreach goes through the document manifest rather than the raw table array, so it does not visit empty slots at all. See RH-97389.
See Also