Properties

ComponentType

#Since v6.0
public override ModelComponentType ComponentType { get; }

Count

Returns the count of all items, including deleted ones.
public virtual int Count { get; }
inherited fromCommonComponentTable<T>

CurrentMaterialIndex

#Since v5.0
At all times, there is a "current" material. Unless otherwise specified, new objects are assigned to the current material. The current material is never locked, hidden, or deleted.
public int CurrentMaterialIndex { get; set; }

CurrentMaterialSource

#Since v5.0
Gets or sets the current material source.
public ObjectMaterialSource CurrentMaterialSource { get; set; }

Document

Document that owns this table.
public RhinoDoc Document { get; }
inherited fromRhinoDocCommonTable<T>

Indexers

this[]

#
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.
public Material this[
index
zero based array index.
] { get; }
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.
If index is out of range, the current material is returned.

Methods

Add

#Since v5.0
Adds a new material to the table based on the default material.
public int Add()
The position of the new material in the table.

Add

#Since v5.0
Adds a new material to the table based on a given material.
public int Add(
Material
material,
A model of the material to be added.
reference
true if this material is supposed to be a reference material. Reference materials are not saved in the file.
)
The position of the new material in the table.

Add

#Since v5.0
Adds a new material to the table based on a given material.
public int Add(
Material
material
A model of the material to be added.
)
The position of the new material in the table.

Clear

Marks all items as deleted.
public void Clear()
inherited fromCommonComponentTable<T>

Delete

#Since v6.0
public override bool Delete(
Material
item
)

DeleteAt

#Since v5.0
Removes a material at a specific position from this material table.
public bool DeleteAt(
materialIndex
The position to be removed.
)
true if successful. false if materialIndex is out of range or the material cannot be deleted because it is the current material or because it material contains active geometry.

Find

#Since v5.0
Finds a material with a matching id.
public int Find(
materialId,
A material ID to be found.
ignoreDeletedMaterials
If true, deleted materials are not checked.
)
>=0 index of the material with the given name -1 no material has the given name.

Find

#Since v8.0
Finds a material index.
public int Find(
Material
material,
Material to search for.
ignoreDeletedMaterials
true means don't search deleted materials.
)
>=0 index of the material -1 no material matchin material.

Find

#Since v5.0
Finds a material with a given name.
public int Find(
materialName,
Name of the material to search for. The search ignores case.
ignoreDeletedMaterials
true means don't search deleted materials.
)
>=0 index of the material with the given name -1 no material has the given name.

FindId

Uses the guid to find a model component. Deleted objects cannot be found by id. The guid is the value that is stored in the .Id property. In a single document, no two active objects have the same guid. If an object is replaced with a new object, then the guid persists. For example, if the _Move command moves an object, then the moved object inherits its guid from the starting object. If the Copy command copies an object, then the copy gets a new guid. This guid persists through file saving/opening operations. This function will not find grip objects.
public virtual T FindId(
id
ID of model component to search for.
)
inherited fromCommonComponentTable<T>
Reference to the rhino object with the objectId or null if no such object could be found.
FindId

FindIndex

#Since v6.0
Retrieves a Material object based on Index. This search type of search is discouraged. We are moving towards using only IDs for all tables.
public Material FindIndex(
index
The index to search for.
)
A Material object, or null if none was found.

GetEnumerator

Returns the enumerator that yields all items.
public virtual IEnumerator<T> GetEnumerator()
inherited fromCommonComponentTable<T>

Modify

#Since v5.0
Modify material settings.
public bool Modify(
Material
newSettings,
This information is copied.
materialIndex,
zero based index of material to set. This must be in the range 0 <= layerIndex < MaterialTable.Count.
quiet
if true, information message boxes pop up when illegal changes are attempted.
)
true if successful. false if materialIndex is out of range or the settings attempt to lock or hide the current material.

ResetMaterial

#Since v5.0
public bool ResetMaterial(
materialIndex
)
Explicit

ICollection<Material>.Add

#Since v5.0
void ICollection<Material>.Add(
Material
item
)