Properties

ActiveCount

#Since v5.0
public int ActiveCount { get; }
Returns number of layers in the layer table, excluding deleted layers.

ComponentType

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

Count

#Since v5.0
public override int Count { get; }
Returns number of layers in the layer table, including deleted layers.

CurrentLayer

#ExampleSince v5.0
public Layer CurrentLayer { get; }
At all times, there is a "current" layer. Unless otherwise specified, new objects are assigned to the current layer. The current layer is never locked, hidden, or deleted. Returns reference to the current layer. Note that this reference may become invalid after a call to AddLayer().

CurrentLayerIndex

#ExampleSince v5.0
public int CurrentLayerIndex { get; }
At all times, there is a "current" layer. Unless otherwise specified, new objects are assigned to the current layer. The current layer is never locked, hidden, or deleted. Returns: Zero based layer table index of the current layer.

Document

#Since v5.0
public RhinoDoc Document { get; }
Document that owns this table.

Indexers

this[]

#
public Layer this[int index] { get; }
Conceptually, the layer table is an array of layers. The operator[] can be used to get individual layers. A layer is either active or deleted and this state is reported by Layer.IsDeleted.
Remarks:

Detaching a worksession reference model, or purging a linked instance definition, removes its layers but leaves the table slots they occupied empty. The slots cannot be closed up, because table indices are persistent references that objects store - object attributes hold a layer index - so renumbering would repoint existing objects at the wrong layer. Count spans the empty slots, and they accumulate for the life of the document - one per purge.

An index that lands on an empty slot returns the document's default layer rather than throwing. Nothing about that layer says it is a stand-in: it reports the name "Default" and ordinary values for every other property, so enumerating a table that has been purged several times reports several layers that are not there. The one distinguishing mark is the index - a stand-in reports Index -1, never the index you asked for - so test index == Layers[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 and is the safer way to walk the table. See RH-97389.

index (int)zero based array index.
Reference to the layer. If layer_index is out of range, the current layer is returned. Note that this reference may become invalid after AddLayer() is called.

Methods

Add

#Since v5.0
public int Add()
Adds a new layer with default definition to the layer table.
index of new layer.

Add

#ExampleSince v5.0
public int Add(Layer layer)
Adds a new layer with specified definition to the layer table.
layer (Layer)definition of new layer. The information in layer is copied. If layer.Name is empty the a unique name of the form "Layer 01" will be automatically created.
>=0 index of new layer -1 layer not added because a layer with that name already exists.

Add

#ExampleSince v5.0
public int Add(string layerName, Color layerColor)
Adds a new layer with specified definition to the layer table.
layerName (string)Name for new layer. Cannot be a null or zero-length string.
layerColor (Color)Color of new layer. Alpha components will be ignored.
>=0 index of new layer -1 layer not added because a layer with that name already exists.

AddPath

#Since v8.0
public int AddPath(string layerPath, Color layerColor)
Adds all of the layer in the specified layer path, beginning with the root. Layer paths contain one or more valid layers names, with each name separated by ModelComponent.NamePathSeparator. For example, "Grandfather::Father::Son".
layerPath (string)The layer path.
layerColor (Color)The color of newly created layers. The colors of layers that already exist will not be changed.
The index of the last layer created if successful, RhinoMath.UnsetIntIndex on failure.

AddPath

#Since v8.0
public int AddPath(string layerPath)
Adds all of the layer in the specified layer path, beginning with the root. Layer paths contain one or more valid layers names, with each name separated by ModelComponent.NamePathSeparator. For example, "Grandfather::Father::Son".
layerPath (string)The layer path.
The index of the last layer created if successful, RhinoMath.UnsetIntIndex on failure.

AddReferenceLayer

#Since v5.0
public int AddReferenceLayer()
Adds a new reference layer with default definition to the layer table. Reference layers are not saved in files.
index of new layer.

AddReferenceLayer

#Since v5.0
public int AddReferenceLayer(Layer layer)
Adds a new reference layer with specified definition to the layer table Reference layers are not saved in files.
layer (Layer)definition of new layer. The information in layer is copied. If layer.Name is empty the a unique name of the form "Layer 01" will be automatically created.
>=0 index of new layer -1 layer not added because a layer with that name already exists.

Clear

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

CreateLayer

#Since v8.6
[CLSCompliant(false)] public int CreateLayer(Layer newLayer, LayerType layerType, uint worksessionReferenceModelSerialNumber, uint linkedInstanceDefinitionSerialNumber)
Basic tool used by the add layer methods.
newLayer (Layer)Settings for new layer. These are copied to the layer table entry and any user data on layer is moved to the layer table entry.
layerType (LayerTable.LayerType)Type type of layer to create.
worksessionReferenceModelSerialNumber (uint)Worksession reference model serial number, where: 0: Layer is not a reference layer. 1: Layer is a reference layer but not part of a worksession reference file. 2-1000: Reserved for future use. >1000: Worksession reference model serial number.
linkedInstanceDefinitionSerialNumber (uint)Linked instance definition serial number, where: 0: Layer is not from a liked instance definition. 1-1000: Reserved for future use. >1000: Linked instance definition serial number.
The index of the last layer created if successful, RhinoMath.UnsetIntIndex on failure.

Delete

#Since v6.0
public bool Delete(Guid layerId, bool quiet)
Deletes layer.
layerId (Guid)Id of the layer to be deleted.
quiet (bool)If true, no warning message box appears if a layer the layer cannot be deleted because it is the current layer or it contains active geometry.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer or because it layer contains active geometry.

Delete

#Since v5.0
public bool Delete(int layerIndex, bool quiet)
Deletes layer.
layerIndex (int)zero based index of layer to delete. This must be in the range 0 <= layerIndex < LayerTable.Count.
quiet (bool)If true, no warning message box appears if a layer the layer cannot be deleted because it is the current layer or it contains active geometry.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer or because it layer contains active geometry.

Delete

#Since v6.0
public bool Delete(Layer layer, bool quiet)
Deletes layer.
layer (Layer)Layer to be deleted.
quiet (bool)If true, no warning message box appears if a layer the layer cannot be deleted because it is the current layer or it contains active geometry.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer or because it layer contains active geometry.

Delete

#Since v6.0
public override bool Delete(Layer layer)
Deletes layer.
layer (Layer)Layer to be deleted.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer or because it layer contains active geometry.

Delete

#Since v8.0
public int Delete(IEnumerable<int> layerIndices, bool quiet)
Deletes layers.
layerIndices (IEnumerable<int>)An enumeration containing the indices of the layers to delete.
quiet (bool)If true, no warning message boxes will appear.
the number of layers that were deleted.

Duplicate

#Since v6.18
public int[] Duplicate(IEnumerable<int> layerIndices, bool duplicateObjects, bool duplicateSublayers)
Duplicates, or copies, one or more layers. Duplicated layers are added to the document.
layerIndices (IEnumerable<int>)The indices of layers to duplicate.
duplicateObjects (bool)If true, then layer objects will also be duplicated and added to the document.
duplicateSublayers (bool)If true, then all sub-layers of the layer will be duplicated.
The indices of the newly added layers if successful, an empty array on failure.

Duplicate

#Since v6.18
public int[] Duplicate(int layerIndex, bool duplicateObjects, bool duplicateSublayers)
Duplicates, or copies, a layer. Duplicated layers are added to the document.
layerIndex (int)The index of the layer to duplicate.
duplicateObjects (bool)If true, then layer objects will also be duplicated and added to the document.
duplicateSublayers (bool)If true, then all sub-layers of the layer will be duplicated.
The indices of the newly added layers if successful, an empty array on failure.

Find

#Since v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(Guid layerId, bool ignoreDeletedLayers, int notFoundReturnValue)
Finds a layer with a matching ID.
layerId (Guid)A valid layer ID.
ignoreDeletedLayers (bool)If true, deleted layers are not checked.
notFoundReturnValue (int)Should be -1 to get the index of the OpenNURBS default layer, or UnsetIntIndex to get an always-out-of-bound value.
The index of the found layer, or notFoundReturnValue.

Find

#Since v5.0 Obsolete v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(Guid layerId, bool ignoreDeletedLayers)
obsoletenotFoundReturnValue should be specified. Add a third argument, its previous value was -1 but consider RhinoMath.UnsetIntIndex.
Finds a layer with a matching ID.
layerId (Guid)A valid layer ID.
ignoreDeletedLayers (bool)If true, deleted layers are not checked.
>=0 index of the layer with the given name -1 no layer has the given name.

Find

#Since v6.0 Obsolete v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(Guid parentId, string layerName, bool ignoreDeletedLayers)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).
Finds a layer with a given name and matching parent ID.
parentId (Guid)A valid layer ID.
layerName (string)name of layer to search for. The search ignores case.
ignoreDeletedLayers (bool)If true, deleted layers are not checked. NOT SUPPORTED FOR NAME SEARCH, only for Guids.
>=0 index of the layer with the given name -1 no layer has the given name.

Find

#Since v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(Guid parentId, string layerName, int notFoundReturnValue)
Finds a layer with a given name and matching parent ID.
parentId (Guid)A valid layer ID.
layerName (string)name of layer to search for. The search ignores case.
notFoundReturnValue (int)Should be -1 to get the index of the OpenNURBS default layer, or UnsetIntIndex to get an always-out-of-bound value.
The index of the found layer, or notFoundReturnValue.

Find

#ExampleSince v5.0 Obsolete v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(string layerName, bool ignoreDeletedLayers)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).
Finds the layer with a given name. If multiple layers exist that have the same name, the first match layer index will be returned.

Deleted layers have no name.

layerName (string)name of layer to search for. The search ignores case.
ignoreDeletedLayers (bool)true means don't search deleted layers.
index of the layer with the given name. If no layer is found, the index of the default layer, -1, is returned.

FindByFullPath

#Since v5.0 Obsolete v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int FindByFullPath(string layerPath, bool ignoreDeletedLayers)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).
layerPath (string)
ignoreDeletedLayers (bool)

FindByFullPath

#Since v6.0
public int FindByFullPath(string layerPath, int notFoundReturnValue)
Searches for a layer using the fully qualified name, that includes ancestors.

Deleted layers have no name.

layerPath (string)The full layer name.
notFoundReturnValue (int)Should be -1 to get the index of the OpenNURBS default layer, or UnsetIntIndex to get an always-out-of-bound value.
The index of the found layer, or notFoundReturnValue.

FindId

public virtual T FindId(Guid id)
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.
inherited fromCommonComponentTable<T>
id (Guid)ID of model component to search for.
Reference to the rhino object with the objectId or null if no such object could be found.
FindId

FindIndex

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

FindName

#Since v6.0
public Layer FindName(string layerName, int startIndex)
Finds the next layer that has an index equal or higher than the searched value.

Search in case-insensitive.

layerName (string)The layer to search for.
startIndex (int)If you specify RhinoMath.UnsetIntIndex, then also default layers will be included. This is the first index that will be tested.
A layer, or null.

FindName

#ExampleSince v6.0
public Layer FindName(string layerName)
Finds the layer with a given name. If multiple layers exist that have the same name, the first match layer index will be returned.

Deleted layers have no name.

The default layer is NOT included in the search. If required, use the overload with startIndex input.

layerName (string)name of layer to search for. The search ignores case.
A layer, or null.

FindNameHash

#Since v6.0
public Layer FindNameHash(NameHash nameHash)
Finds a Layer given its name hash.
nameHash (NameHash)The name hash of the Layer to be searched.
An Layer, or null on error.

FindNext

#Since v5.0 Obsolete v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public int FindNext(int index, string layerName, bool ignoreDeletedLayers)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).
index (int)
layerName (string)
ignoreDeletedLayers (bool)

FindNext

#Since v6.0
[EditorBrowsable(EditorBrowsableState.Never)] public Layer FindNext(int index, string layerName)
Use FindName(name, index).
index (int)Do not use.
layerName (string)Do not use.
Do not use.

ForceLayerVisible

#Since v5.0
public bool ForceLayerVisible(Guid layerId)
Makes a layer and all of its parent layers visible.
layerId (Guid)The layer ID to be made visible.
true if the operation succeeded.

ForceLayerVisible

#Since v5.0
public bool ForceLayerVisible(int layerIndex)
Makes a layer and all of its parent layers visible.
layerIndex (int)The layer index to be made visible.
true if the operation succeeded.

GetEnumerator

#Since v5.0
public override IEnumerator<Layer> GetEnumerator()

GetSelected

#
public bool GetSelected(out List<int> layerIndices)
Returns the indices of layers that are selected on the Layer user interface.
layerIndices (out List<int>)The indices of selected layers.
true if the layer user interface is visible, false otherwise.

GetSorted

#Since v7.34
public int[] GetSorted()
Gets an array of layer indices that are sorted by the values of Layer.SortIndex.
An array of layer indices.

GetUnusedLayerName

#ExampleSince v6.0
public string GetUnusedLayerName()
Gets the next unused layer name used as default when creating new layers.
An unused layer name string.

GetUnusedLayerName

#ExampleSince v5.0 Obsolete v6.0
public string GetUnusedLayerName(bool ignoreDeleted)
obsolete'ignoreDeleted' is now redundant. Layers are now permanently removed. Use the overload with this argument.
Gets the next unused layer name used as default when creating new layers.
ignoreDeleted (bool)If this is true then Rhino may use a name used by a deleted layer.
An unused layer name string.

Modify

#Since v6.0
public bool Modify(Layer newSettings, Guid layerId, bool quiet)
Modifies layer settings.
newSettings (Layer)This information is copied.
layerId (Guid)Id of layer.
quiet (bool)if false, information message boxes pop up when illegal changes are attempted.
true if successful. false if layerIndex is out of range or the settings attempt to lock or hide the current layer.

Modify

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

Purge

#Since v6.0
public bool Purge(Guid layerId, bool quiet)
Deletes a layer and all geometry objects on a layer.
layerId (Guid)Id of the layer to purge.
quiet (bool)If true, no warning message box appears if a layer the layer cannot be deleted because it is the current layer.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer.

Purge

#Since v5.5
public bool Purge(int layerIndex, bool quiet)
Deletes a layer and all geometry objects on a layer
layerIndex (int)zero based index of layer to delete. This must be in the range 0 <= layerIndex < LayerTable.Count.
quiet (bool)If true, no warning message box appears if a layer the layer cannot be deleted because it is the current layer.
true if successful. false if layerIndex is out of range or the layer cannot be deleted because it is the current layer.

PurgeUnused

#Since v9.0
public int PurgeUnused()
Purges any unused layers.
The number of unused layers that were purged.

Select

#Since v6.0
public bool Select(IEnumerable<int> layerIndices, bool bDeselect)
Selects layers in the Layer user interface.
layerIndices (IEnumerable<int>)The indices of layers to select.
bDeselect (bool)If true, then any previously selected layers will be unselected.
true if the layer user interface is visible, false otherwise.

SetCurrentLayerIndex

#Since v5.0
public bool SetCurrentLayerIndex(int layerIndex, bool quiet)
At all times, there is a "current" layer. Unless otherwise specified, new objects are assigned to the current layer. The current layer is never locked, hidden, or deleted.
layerIndex (int)Value for new current layer. 0 <= layerIndex < LayerTable.Count. The layer's mode is automatically set to NormalMode.
quiet (bool)if true, then no warning message box pops up if the current layer request can't be satisfied.
true if current layer index successfully set.

Sort

#Since v8.0
public void Sort(IEnumerable<int> layerIndices)
Updates the layer sort order
layerIndices (IEnumerable<int>)The sort order.

SortByLayerName

#Since v8.2
public void SortByLayerName(bool bAscending)
Sort layers, in the layer table, by their name in either ascending or descending order. This function sorts layers in the same manner as Rhino's Layers panel.
Remarks: This function changes the value of Layer.SortIndex. It does not change the index order of layers in the layer table.
bAscending (bool)Sort in ascending (true) or descending (false) order.
Explicit

ICollection<Layer>.Add

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

Undelete

#Since v5.0
public bool Undelete(int layerIndex)
Undeletes a layer that has been deleted by DeleteLayer().
layerIndex (int)zero based index of layer to undelete. This must be in the range 0 <= layerIndex < LayerTable.Count.
true if successful.

UndoModify

#Since v6.0
[CLSCompliant(false)] public bool UndoModify(Guid layerId, uint undoRecordSerialNumber)
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
layerId (Guid)The layer Id to be used.
undoRecordSerialNumber (uint)The undo record serial number. Pass 0 not to specify one.
true if this layer had been modified and the modifications were undone.

UndoModify

#Since v6.0
public bool UndoModify(Guid layerId)
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
layerId (Guid)The layer Id to be used.
true if this layer had been modified and the modifications were undone.

UndoModify

#Since v5.0
[CLSCompliant(false)] public bool UndoModify(int layerIndex, uint undoRecordSerialNumber)
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
layerIndex (int)The layer index to be used.
undoRecordSerialNumber (uint)The undo record serial number. Pass 0 not to specify one.
true if this layer had been modified and the modifications were undone.

UndoModify

#Since v5.0
public bool UndoModify(int layerIndex)
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
layerIndex (int)The layer index to be used.
true if this layer had been modified and the modifications were undone.