ObjectEnumeratorSettings

References
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
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;
    }
  }
}
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()

Constructors

ObjectEnumeratorSettings

#ExampleSince v5.0
public ObjectEnumeratorSettings()
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.

Properties

ActiveObjects

#Since v5.0
public bool ActiveObjects { get; set; }
When true, objects that are part of current model and saved in file are returned.

ClassTypeFilter

#Since v5.0
public Type ClassTypeFilter { get; set; }

DeletedObjects

#Since v5.0
public bool DeletedObjects { get; set; }
When true, deleted objects are returned.

HiddenObjects

#Since v5.0
public bool HiddenObjects { get; set; }
When true, hidden objects or objects on hidden layers are returned.

IdefObjects

#Since v5.0
public bool IdefObjects { get; set; }
When true, objects in instance definitions (not the instance references) are returned.

IncludeGrips

#ExampleSince v5.0
public bool IncludeGrips { get; set; }
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.

IncludeLights

#ExampleSince v5.0
public bool IncludeLights { get; set; }
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.

IncludeMarkups

#Since v9.0
public bool IncludeMarkups { get; set; }
Markup content objects are skipped by default. Set this to true to include them along with all other objects.

IncludePhantoms

#Since v5.0
public bool IncludePhantoms { get; set; }
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.

LayerIndexFilter

#Since v5.0
public int LayerIndexFilter { get; set; }
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.

LockedObjects

#Since v5.0
public bool LockedObjects { get; set; }
When true, locked objects or objects on locked layers are returned.

MarkupIdFilter

#Since v9.0
public Guid MarkupIdFilter { get; set; }
When IncludeMarkups is true, includes only the content of the markup with this id; other objects are unaffected. Guid.Empty, the default, includes the content of every markup.

MaterialIndexFilter

#Since v8.25
public int MaterialIndexFilter { get; set; }
The material filter property can be used to limit the iteration to objects that use a specific material. The default is to iterate through all objects no matter the material assignment.

NameFilter

#ExampleSince v5.0
public string NameFilter { get; set; }
The name filter property can be used to limit the iteration to objects with a specific name.

NormalObjects

#Since v5.0
public bool NormalObjects { get; set; }
When true, normal objects (e.g. not locked and not hidden) are returned.

ObjectTypeFilter

#Since v5.0
[CLSCompliant(false)] public ObjectType ObjectTypeFilter { get; set; }
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.

ReferenceObjects

#Since v5.0
public bool ReferenceObjects { get; set; }
When true, objects that are for reference and not saved in file are returned.

SelectedObjectsFilter

#Since v5.0
public bool SelectedObjectsFilter { get; set; }
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.

SpaceFilter

#Since v9.0
public ActiveSpace SpaceFilter { get; set; }
The viewport filter property can be used to limit the iteration to objects that reside on specific space.

SubObjectSelected

#Since v7.3
public bool SubObjectSelected { get; set; }
If true then objects which only have a sub object selected will be included. This is false by default.

UseFastSelection

#Since v9.0
public bool UseFastSelection { get; set; }
When SelectedObjectsFilter is true, enables an optimized iterator that walks only the document's selected objects rather than scanning the whole object table. Use this for selection-driven UI that re-queries on every selection change (e.g. panel enable-state). Only valid for the current selection set: do not use it while selection is actively changing. Ignored unless SelectedObjectsFilter is also true.

ViewportFilter

#Since v5.6
public RhinoViewport ViewportFilter { get; set; }
The viewport filter property can be used to limit the iteration to objects that are active in a specific viewport.

VisibleFilter

#Since v5.0
public bool VisibleFilter { get; set; }
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.