I wanne retreive all RhinoObjects that are currently hidden in the Viewport (done via the Hide Command), but the problem is that doc.Objects cant event find those objects.
Am I using the right tool, here?
The idea is, that we wanne give the user feedback, about objects that are hidden and have UserDefinedData.
This was a first test, using C#7.3:
using Rhino;
using Rhino.DocObjects;
using Rhino.Commands;
using System.Collections.Generic;
public class GetHiddenObjectGuids : Command
{
public override string EnglishName => "GetHiddenObjectGuids";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
List<System.Guid> invisibleObjectGuids = new List<System.Guid>();
List<System.Guid> allObjectsGuids = new List<System.Guid>();
foreach (RhinoObject obj in doc.Objects)
{
allObjectsGuids.Add(obj.Id);
bool isHidden = obj.IsHidden;
bool isOnHiddenLayer = !doc.Layers[obj.Attributes.LayerIndex].IsVisible;
if (isHidden || isOnHiddenLayer)
{
invisibleObjectGuids.Add(obj.Id);
}
}
foreach (var guid in invisibleObjectGuids)
{
RhinoApp.WriteLine($"Invisible: {guid.ToString()}");
}
foreach(var guid in allObjectsGuids)
{
RhinoApp.WriteLine($"Not Invisible: {guid.ToString()}");
}
return Result.Success;
}
}