ObjectEnumeratorSettings Class

ObjectEnumeratorSettings Class

Settings used for getting an enumerator of objects in a document See Rhino.Collections.ObjectTable.GetEnumerator()
Inheritance Hierarchy
SystemObject
  Rhino.DocObjectsObjectEnumeratorSettings

Namespace:  Rhino.DocObjects
Assembly:  RhinoCommon (in RhinoCommon.dll)
Syntax
public class ObjectEnumeratorSettings
Public Class ObjectEnumeratorSettings

The ObjectEnumeratorSettings type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleObjectEnumeratorSettings
Initializes a new instance of the ObjectEnumeratorSettings class
Top
Properties
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;

namespace examples_cs
{
  public class MoveSelectedObjectsToCurrentLayerCommand : Command
  {
    public override string EnglishName
    {
      get { return "csMoveSelectedObjectsToCurrentLayer"; }
    }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      // all non-light objects that are selected
      var object_enumerator_settings = new ObjectEnumeratorSettings();
      object_enumerator_settings.IncludeLights = false;
      object_enumerator_settings.IncludeGrips = true;
      object_enumerator_settings.NormalObjects = true;
      object_enumerator_settings.LockedObjects = true;
      object_enumerator_settings.HiddenObjects = true;
      object_enumerator_settings.ReferenceObjects = true;
      object_enumerator_settings.SelectedObjectsFilter = true;
      var selected_objects = doc.Objects.GetObjectList(object_enumerator_settings);

      var current_layer_index = doc.Layers.CurrentLayerIndex;
      foreach (var selected_object in selected_objects)
      {
        selected_object.Attributes.LayerIndex = current_layer_index;
        selected_object.CommitChanges();
      }
      doc.Views.Redraw();
      return Result.Success;
    }
  }
}
Imports Rhino
Imports Rhino.Commands
Imports Rhino.DocObjects

Namespace examples_vb
  Public Class MoveSelectedObjectsToCurrentLayerCommand
    Inherits Command
    Public Overrides ReadOnly Property EnglishName() As String
      Get
        Return "vbMoveSelectedObjectsToCurrentLayer"
      End Get
    End Property

    Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
      ' all non-light objects that are selected
      Dim object_enumerator_settings = New ObjectEnumeratorSettings()
      object_enumerator_settings.IncludeLights = False
      object_enumerator_settings.IncludeGrips = True
      object_enumerator_settings.NormalObjects = True
      object_enumerator_settings.LockedObjects = True
      object_enumerator_settings.HiddenObjects = True
      object_enumerator_settings.ReferenceObjects = True
      object_enumerator_settings.SelectedObjectsFilter = True
      Dim selected_objects = doc.Objects.GetObjectList(object_enumerator_settings)

      Dim current_layer_index = doc.Layers.CurrentLayerIndex
      For Each selected_object As RhinoObject In selected_objects
        selected_object.Attributes.LayerIndex = current_layer_index
        selected_object.CommitChanges()
      Next
      doc.Views.Redraw()
      Return Result.Success
    End Function
  End Class
End Namespace
Python
from Rhino import *
from Rhino.Commands import *
from Rhino.DocObjects import *
from scriptcontext import doc

def RunCommand():
  # all non-light objects that are selected
  object_enumerator_settings = ObjectEnumeratorSettings()
  object_enumerator_settings.IncludeLights = False
  object_enumerator_settings.IncludeGrips = True
  object_enumerator_settings.NormalObjects = True
  object_enumerator_settings.LockedObjects = True
  object_enumerator_settings.HiddenObjects = True
  object_enumerator_settings.ReferenceObjects = True
  object_enumerator_settings.SelectedObjectsFilter = True
  selected_objects = doc.Objects.GetObjectList(object_enumerator_settings)

  current_layer_index = doc.Layers.CurrentLayerIndex
  for selected_object in selected_objects:
    selected_object.Attributes.LayerIndex = current_layer_index
    selected_object.CommitChanges()

  doc.Views.Redraw()
  return Result.Success

if __name__ == "__main__":
  RunCommand()
Version Information

Rhino for Mac

Supported in: 5.4

Rhino for Windows

Supported in: 6.14
See Also