Properties

ActiveCount

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

ComponentType

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

Count

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

CurrentLayer

#ExampleSince v5.0
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().
public Layer CurrentLayer { get; }

CurrentLayerIndex

#ExampleSince v5.0
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.
public int CurrentLayerIndex { get; }

Document

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

Indexers

this[]

#
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.
public Layer this[
index
zero based array index.
] { get; }
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.

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
Adds a new layer with default definition to the layer table.
public int Add()
index of new layer.

Add

#ExampleSince v5.0
Adds a new layer with specified definition to the layer table.
public int Add(
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
Adds a new layer with specified definition to the layer table.
public int Add(
layerName,
Name for new layer. Cannot be a null or zero-length string.
layerColor
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
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".
public int AddPath(
layerPath,
The layer path.
layerColor
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
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".
public int AddPath(
layerPath
The layer path.
)
The index of the last layer created if successful, RhinoMath.UnsetIntIndex on failure.

AddReferenceLayer

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

AddReferenceLayer

#Since v5.0
Adds a new reference layer with specified definition to the layer table Reference layers are not saved in files.
public int AddReferenceLayer(
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

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

CreateLayer

#Since v8.6
Basic tool used by the add layer methods.
[CLSCompliant(false)] public int CreateLayer(
newLayer,
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,
Type type of layer to create.
worksessionReferenceModelSerialNumber,
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
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
Deletes layer.
public bool Delete(
layerId,
Id of the layer to be deleted.
quiet
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
Deletes layer.
public bool Delete(
layerIndex,
zero based index of layer to delete. This must be in the range 0 <= layerIndex < LayerTable.Count.
quiet
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
Deletes layer.
public bool Delete(
layer,
Layer to be deleted.
quiet
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
Deletes layer.
public override bool Delete(
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
Deletes layers.
public int Delete(
layerIndices,
An enumeration containing the indices of the layers to delete.
quiet
If true, no warning message boxes will appear.
)
the number of layers that were deleted.

Duplicate

#Since v6.18
Duplicates, or copies, one or more layers. Duplicated layers are added to the document.
public int[] Duplicate(
layerIndices,
The indices of layers to duplicate.
duplicateObjects,
If true, then layer objects will also be duplicated and added to the document.
duplicateSublayers
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
Duplicates, or copies, a layer. Duplicated layers are added to the document.
public int[] Duplicate(
layerIndex,
The index of the layer to duplicate.
duplicateObjects,
If true, then layer objects will also be duplicated and added to the document.
duplicateSublayers
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
Finds a layer with a matching ID.
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(
layerId,
A valid layer ID.
ignoreDeletedLayers,
If true, deleted layers are not checked.
notFoundReturnValue
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
Finds a layer with a matching ID.
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(
layerId,
A valid layer ID.
ignoreDeletedLayers
If true, deleted layers are not checked.
)
obsoletenotFoundReturnValue should be specified. Add a third argument, its previous value was -1 but consider RhinoMath.UnsetIntIndex.
>=0 index of the layer with the given name -1 no layer has the given name.

Find

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

Find

#Since v6.0
Finds a layer with a given name and matching parent ID.
[EditorBrowsable(EditorBrowsableState.Never)] public int Find(
parentId,
A valid layer ID.
layerName,
name of layer to search for. The search ignores case.
notFoundReturnValue
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
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.

[EditorBrowsable(EditorBrowsableState.Never)] public int Find(
layerName,
name of layer to search for. The search ignores case.
ignoreDeletedLayers
true means don't search deleted layers.
)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).
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(
layerPath,
ignoreDeletedLayers
)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).

FindByFullPath

#Since v6.0
Searches for a layer using the fully qualified name, that includes ancestors.

Deleted layers have no name.

public int FindByFullPath(
layerPath,
The full layer name.
notFoundReturnValue
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

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 Layer object based on Index. This search type of search is discouraged. We are moving towards using only IDs for all tables.
public Layer FindIndex(
index
The index to search for.
)
A Layer object, or null if none was found.

FindName

#Since v6.0
Finds the next layer that has an index equal or higher than the searched value.

Search in case-insensitive.

public Layer FindName(
layerName,
The layer to search for.
startIndex
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
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.

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

FindNameHash

#Since v6.0
Finds a Layer given its name hash.
public Layer FindNameHash(
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(
index,
layerName,
ignoreDeletedLayers
)
obsoleteignoreDeletedLayers is no longer supported for research by name. Use the overload with notFoundReturnValue (-1 was the previous default).

FindNext

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

ForceLayerVisible

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

ForceLayerVisible

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

GetEnumerator

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

GetSelected

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

GetSorted

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

GetUnusedLayerName

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

GetUnusedLayerName

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

Modify

#Since v6.0
Modifies layer settings.
public bool Modify(
newSettings,
This information is copied.
layerId,
Id of layer.
quiet
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
Modifies layer settings.
public bool Modify(
newSettings,
This information is copied.
layerIndex,
zero based index of layer to set. This must be in the range 0 <= layerIndex < LayerTable.Count.
quiet
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
Deletes a layer and all geometry objects on a layer.
public bool Purge(
layerId,
Id of the layer to purge.
quiet
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
Deletes a layer and all geometry objects on a layer
public bool Purge(
layerIndex,
zero based index of layer to delete. This must be in the range 0 <= layerIndex < LayerTable.Count.
quiet
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
Purges any unused layers.
public int PurgeUnused()
The number of unused layers that were purged.

Select

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

SetCurrentLayerIndex

#Since v5.0
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.
public bool SetCurrentLayerIndex(
layerIndex,
Value for new current layer. 0 <= layerIndex < LayerTable.Count. The layer's mode is automatically set to NormalMode.
quiet
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
Updates the layer sort order
public void Sort(
layerIndices
The sort order.
)

SortByLayerName

#Since v8.2
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.
public void SortByLayerName(
bAscending
Sort in ascending (true) or descending (false) order.
)
Remarks: This function changes the value of Layer.SortIndex. It does not change the index order of layers in the layer table.
Explicit

ICollection<Layer>.Add

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

Undelete

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

UndoModify

#Since v6.0
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
[CLSCompliant(false)] public bool UndoModify(
layerId,
The layer Id to be used.
undoRecordSerialNumber
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
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
public bool UndoModify(
layerId
The layer Id to be used.
)
true if this layer had been modified and the modifications were undone.

UndoModify

#Since v5.0
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
[CLSCompliant(false)] public bool UndoModify(
layerIndex,
The layer index to be used.
undoRecordSerialNumber
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
Restores the layer to its previous state, if the layer has been modified and the modification can be undone.
public bool UndoModify(
layerIndex
The layer index to be used.
)
true if this layer had been modified and the modifications were undone.