How to get hidden instance references with c#

Hello,

Dynamic Geometry Pipeline from Human and Reference By Type from elefront are powerfull tools for blocks management. Despite its incredible efficiency the first runs each time you make a modification, and the other one can be really slow with big model (maybe for a good reason).

I tried to create a c# componant i can update when i want. It works really fine but instead of giving me all references, i only get visible instance references unlike Dynamic geometry and elefront.

Here the code

    var instanceObjects = new List<InstanceObject>();

    var instanceReferences = doc.Objects.FindByObjectType(ObjectType.InstanceReference);
    foreach (var reference in instanceReferences)
    {
      var instanceObject = reference as InstanceObject;
      if (instanceObject != null)
      {
        instanceObjects.Add(instanceObject);
      }
      else
      {
        instanceObjects.Add(null);
      }
    }
    instances = instanceObjects;

I tried many way to get instances references from doc.Objects but always got only visible Instance References. I think they can’t be find there.

Any advices ?

Hi,
You can use method RhinoDoc.ActiveDoc.Objects.GetObjectsByType( ObjectEnumeratorSettings settings) with parameter ObjectEnumeratorSettings settings where you set properties for objects to fit search criteria:

// SET SEARCH CRITERIA...
var objSetting = new Rhino.DocObjects.ObjectEnumeratorSettings();
objSetting.HiddenObjects = true;
objSetting.ObjectTypeFilter = Rhino.DocObjects.ObjectType.InstanceReference;
// PERFORM SEARCH...
var objInstances = RhinoDoc.ActiveDoc.Objects.GetObjectsByType<Rhino.DocObjects.RhinoObject>(objSetting);

Amazing ! Thanks a lot ! These four little lines will relieve my processes a lot ! :slight_smile:
Have a pleasant day !