Click or drag to resize

ObjectEnumeratorSettings Class

Inheritance Hierarchy
SystemObject
  Rhino.DocObjectsObjectEnumeratorSettings

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

The ObjectEnumeratorSettings type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleObjectEnumeratorSettings
Constructs object enumerator settings that will iterate the document looking for normal object and locked object that are active, or part of current model and saved in file.
Top
Properties
  NameDescription
Public propertyActiveObjects
When true, objects that are part of current model and saved in file are returned.
Public propertyClassTypeFilter
Public propertyDeletedObjects
When true, deleted objects are returned.
Public propertyHiddenObjects
When true, hidden objects or objects on hidden layers are returned.
Public propertyIdefObjects
When true, objects in instance definitions (not the instance references) are returned.
Public propertyCode exampleIncludeGrips
The default object enumerator settings will not iterate through grip objects. If you want the iterator to include grips, then set this property to true.
Public propertyCode exampleIncludeLights
The default object enumerator settings will not iterate through render light objects. If you want the iterator to include lights, then set this property to true.
Public propertyIncludePhantoms
The default object enumerator settings will not iterate through phantom objects. If you want the iterator to include phantom objects, then set this property to true.
Public propertyLayerIndexFilter
The layer filter property can be used to limit the iteration to objects on a specific layer. The default is to iterate through all layers.
Public propertyLockedObjects
When true, locked objects or objects on locked layers are returned.
Public propertyCode exampleNameFilter
The name filter property can be used to limit the iteration to objects with a specific name.
Public propertyNormalObjects
When true, normal objects (e.g. not locked and not hidden) are returned.
Public propertyObjectTypeFilter
The object type filter property can be used to limit the iteration to specific types of geometry. The default is to iterate all objects types.
Public propertyReferenceObjects
When true, objects that are for reference and not saved in file are returned.
Public propertySelectedObjectsFilter
The default object enumerator settings ignore the selected state of objects. If you want the iterator to limit itself to selected objects, then set this property to true.
Public propertySubObjectSelected
If true then objects which only have a sub object selected will be included. This is false by default.
Public propertyViewportFilter
The viewport filter property can be used to limit the iteration to objects that are active in a specific viewport.
Public propertyVisibleFilter
The default object enumerator settings ignore the visibility state of objects. If you want the iterator to limit itself to visible objects, then set this property to true.
Top
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;
    }
  }
}
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()
See Also